(or transient-mark-mode (setq transient-mark-mode 'only))
(set-mark (mark t)))))
+;; Improved compilation machinery.
+
+(setq compile-command
+ (let ((ncpu (with-temp-buffer
+ (insert-file-contents "/proc/cpuinfo")
+ (buffer-string)
+ (count-matches "^processor\\s-*:"))))
+ (format "make -j%d -k" (* 2 ncpu))))
+
+(defun mdw-compilation-buffer-name (mode)
+ (concat "*" (downcase mode) ": "
+ (abbreviate-file-name default-directory) "*"))
+(setq compilation-buffer-name-function 'mdw-compilation-buffer-name)
+
+(eval-after-load "compile"
+ '(progn
+ (define-key compilation-shell-minor-mode-map "\C-c\M-g" 'recompile)))
+
+(defun mdw-compile (command &optional directory comint)
+ "Initiate a compilation COMMAND, maybe in a different DIRECTORY.
+The DIRECTORY may be nil to not change. If COMINT is t, then
+start an interactive compilation.
+
+Interactively, prompt for the command if the variable
+`compilation-read-command' is non-nil, or if requested through
+the prefix argument. Prompt for the directory, and run
+interactively, if requested through the prefix.
+
+Use a prefix of 4, 6, 12, or 14, or type C-u between one and three times, to
+force prompting for a directory.
+
+Use a prefix of 2, 6, 10, or 14, or type C-u three times, to force
+prompting for the command.
+
+Use a prefix of 8, 10, 12, or 14, or type C-u twice or three times,
+to force interactive compilation."
+ (interactive
+ (let* ((prefix (prefix-numeric-value current-prefix-arg))
+ (command (eval compile-command))
+ (dir (and (plusp (logand prefix #x54))
+ (read-directory-name "Compile in directory: "))))
+ (list (if (or compilation-read-command
+ (plusp (logand prefix #x42)))
+ (compilation-read-command command)
+ command)
+ dir
+ (plusp (logand prefix #x58)))))
+ (let ((default-directory (or directory default-directory)))
+ (compile command comint)))
+
;; Functions for sexp diary entries.
(defun mdw-not-org-mode (form)
(decf n)))))))
(defun mdw-mpc-select-one ()
- (unless (get-char-property (point) 'mpc-select)
+ (when (and (get-char-property (point) 'mpc-file)
+ (not (get-char-property (point) 'mpc-select)))
(mpc-select-toggle)))
(defun mdw-mpc-unselect-one ()
(defun mdw-mpc-select (&optional arg interactivep)
(interactive (list current-prefix-arg t))
- (mdw-mpc-hack-lines arg interactivep 'mdw-mpc-select-one)
- (mpc-selection-refresh))
+ (mdw-mpc-hack-lines arg interactivep 'mdw-mpc-select-one))
(defun mdw-mpc-unselect (&optional arg interactivep)
(interactive (list current-prefix-arg t))
- (mdw-mpc-hack-lines arg interactivep 'mdw-mpc-unselect-one)
- (mpc-selection-refresh))
+ (mdw-mpc-hack-lines arg interactivep 'mdw-mpc-unselect-one))
(defun mdw-mpc-unselect-backwards (arg)
(interactive "p")
- (mdw-mpc-hack-lines (- arg) t 'mdw-mpc-unselect-one)
- (mpc-selection-refresh))
+ (mdw-mpc-hack-lines (- arg) t 'mdw-mpc-unselect-one))
(defun mdw-mpc-unselect-all ()
(interactive)
(beginning-of-line)
(forward-line (- arg)))
+(defun mdw-mpc-playlist-add (&optional arg interactivep)
+ (interactive (list current-prefix-arg t))
+ (let ((mpc-select mpc-select))
+ (when (or arg (and interactivep (use-region-p)))
+ (setq mpc-select nil)
+ (mdw-mpc-hack-lines arg interactivep 'mdw-mpc-select-one))
+ (setq mpc-select (reverse mpc-select))
+ (mpc-playlist-add)))
+
+(defun mdw-mpc-playlist-delete (&optional arg interactivep)
+ (interactive (list current-prefix-arg t))
+ (setq mpc-select (nreverse mpc-select))
+ (mpc-select-save
+ (when (or arg (and interactivep (use-region-p)))
+ (setq mpc-select nil)
+ (mpc-selection-refresh)
+ (mdw-mpc-hack-lines arg interactivep 'mdw-mpc-select-one))
+ (mpc-playlist-delete)))
+
+(defun mdw-mpc-hack-tagbrowsers ()
+ (setq-local mode-line-format
+ '("%e"
+ mode-line-frame-identification
+ 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)
(define-key mpc-mode-map "\e\177" 'mdw-mpc-unselect-all)
(define-key mpc-mode-map "n" 'mdw-mpc-next-line)
(define-key mpc-mode-map "p" 'mdw-mpc-previous-line)
+ (define-key mpc-mode-map "/" 'mpc-songs-search)
(setq mpc-songs-mode-map (make-sparse-keymap))
(set-keymap-parent mpc-songs-mode-map mpc-mode-map)
(define-key mpc-songs-mode-map "l" 'mpc-playlist)
- (define-key mpc-songs-mode-map "+" 'mpc-playlist-add)
- (define-key mpc-songs-mode-map "-" 'mpc-playlist-delete)))
+ (define-key mpc-songs-mode-map "+" 'mdw-mpc-playlist-add)
+ (define-key mpc-songs-mode-map "-" 'mdw-mpc-playlist-delete)
+ (define-key mpc-songs-mode-map "\r" 'mpc-songs-jump-to)))
;;;--------------------------------------------------------------------------
;;; Inferior Emacs Lisp.