emms-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emms-help] emms-playlist-current-changed-hook


From: Daniel Brockman
Subject: [emms-help] emms-playlist-current-changed-hook
Date: Thu, 16 Jun 2005 19:59:41 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Last night on #emacs, Trent Buck wrote:

      <twb> Is there an EMMS hook that runs every time the    [21:08]
            track changes?

      [...]
      
      <twb> This is a silly name:                             [21:13]
            emms-playlist-current-changed-hook.
   <Dabian> found a better name?
      <twb> It sounds like it gets run whenever you add / delete
            tracks from the playlist.
      <twb> Really it's run whenever the (current) *track*    [21:14]
            changes.
   <Dabian> "current-changed-hook" ?
      <twb> I suppose it's because it's in the "emms-playlist"
            package...

I don't know if there ever was an emms-playlist package, but all the
basic playlist stuff is in emms.el now anyway.

So how about this?

--- emms.el     16 Jun 2005 02:06:51 +0200      1.47
+++ emms.el     16 Jun 2005 15:34:42 +0200      
@@ -124,11 +124,15 @@
   :group 'emms
   :type 'hook)
 
-(defcustom emms-playlist-current-changed-hook nil
+(defcustom emms-current-track-changed-hook nil
   "*Hook run after EMMS switches to a new track."
   :group 'emms
   :type 'hook)
 
+(emms-define-obsolete-variable-alias
+  'emms-playlist-current-changed-hook
+  'emms-current-track-changed-hook)
+
 (defcustom emms-track-initialize-functions nil
   "*List of functions to call for each new EMMS track.
 This can be used to initialize tracks with various info."
@@ -393,9 +397,9 @@
 
 (defun emms-playlist-set-current (n)
   "Set the current track in the EMMS playlist to N (a number).
-This runs `emms-playlist-current-changed-hook'."
+This runs `emms-current-track-changed-hook'."
   (setq emms-playlist-current n)
-  (run-hooks 'emms-playlist-current-changed-hook))
+  (run-hooks 'emms-current-track-changed-hook))
 
 (defun emms-playlist-get-current ()
   "Return the index number of the current EMMS track.

--- emms-mode-line.el   20 May 2005 12:28:43 +0200      1.1
+++ emms-mode-line.el   16 Jun 2005 15:35:36 +0200      
@@ -63,7 +63,7 @@
   (or global-mode-string (setq global-mode-string '("")))
   (if (and arg (> arg 0))
       (progn
-       (add-hook 'emms-playlist-current-changed-hook 'emms-mode-line-alter)
+       (add-hook 'emms-current-track-changed-hook 'emms-mode-line-alter)
        (add-hook 'emms-player-finished-hook 'emms-mode-line-blank)
        (add-hook 'emms-player-stopped-hook 'emms-mode-line-blank)
        (add-hook 'emms-player-started-hook 'emms-mode-line-alter)      
@@ -73,7 +73,7 @@
                (append global-mode-string
                        '(emms-mode-line-string))))
        (when emms-player-playing-p (emms-mode-line-alter)))
-    (remove-hook 'emms-playlist-current-changed-hook 'emms-mode-line-alter)
+    (remove-hook 'emms-current-track-changed-hook 'emms-mode-line-alter)
     (remove-hook 'emms-player-finished-hook 'emms-mode-line-blank)
     (remove-hook 'emms-player-stopped-hook 'emms-mode-line-blank)
     (remove-hook 'emms-player-started-hook 'emms-mode-line-alter)
I think this is actually indicative of a bigger problem in EMMS.
There are quite a few (IMHO) less-than-perfect names due to everything
being prefixed with the name of the ``package'' it's in.

Take `emms-playlist-get-track-description'.  This function takes a
track and returns a user-friendly description of that track.
It doesn't even have anything to do with the playlist!

Most of the stuff in emms-mode-line.el could probably do without the
`mode-line-' prefix.  Of course, `emms-mode-line-mode-line-function'
is a particularly ridiculous example.

Do people consider prefixing names in this way a Good Thing?

Could these names be side-effects of a wicked attempt at making the
code more ``object-orientated''?  (As my systems analysis teacher kept
insisting was the correct pronunciation.)

Will the other developers condone my actions if I begin wrecking havoc
and causing general mayhem in a crusade against superfluous affixes?

Should I stop talking like I'm trying to overdramatize a cliff hanger
for a television series?

Stay tuned.

-- 
Daniel Brockman <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]