chiark / gitweb /
el/dot-emacs.el: Redefine the playlist header line to preserve mark.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 20 Jul 2017 00:23:32 +0000 (01:23 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 20 Jul 2017 00:23:32 +0000 (01:23 +0100)
The definition of the header line has some Lisp code which inserts stuff
into a temporary buffer, and that sets `deactivate-mark'.  Preserve this
variable so the mark remains active after cursor movement.

el/dot-emacs.el

index 3ea5cd5ab9fe0fc11e68cbd0a161d796a98b9c14..7f6f3fb89278d523d99d58c78b8de9f21e694998 100644 (file)
@@ -3899,6 +3899,23 @@ (defun mdw-mpc-hack-tagbrowsers ()
                mode-line-buffer-identification)))
 (add-hook 'mpc-tagbrowser-mode-hook 'mdw-mpc-hack-tagbrowsers)
 
+(defun mdw-mpc-hack-songs ()
+  (setq-local header-line-format
+             ;; '("MPC " mpc-volume " " mpc-current-song)
+             (list (propertize " " 'display '(space :align-to 0))
+                   ;; 'mpc-songs-format-description
+                   '(:eval
+                     (let ((deactivate-mark) (hscroll (window-hscroll)))
+                       (with-temp-buffer
+                         (mpc-format mpc-songs-format 'self hscroll)
+                         ;; That would be simpler than the hscroll handling in
+                         ;; mpc-format, but currently move-to-column does not
+                         ;; recognize :space display properties.
+                         ;; (move-to-column hscroll)
+                         ;; (delete-region (point-min) (point))
+                         (buffer-string)))))))
+(add-hook 'mpc-songs-mode-hook 'mdw-mpc-hack-songs)
+
 (eval-after-load "mpc"
   '(progn
      (define-key mpc-mode-map "m" 'mdw-mpc-select)