X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/75019c667e1f02687f65f2e4b690c3d8c3df9ca6..be21efd0c0776326e0d2bdb770d17b8cbffae18c:/el/dot-emacs.el diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 3ea5cd5..efbc6ee 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -293,6 +293,56 @@ it's currently off." (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) @@ -3892,6 +3942,25 @@ there is sadness." (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" @@ -3899,6 +3968,23 @@ there is sadness." 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) @@ -3911,8 +3997,8 @@ there is sadness." (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))) ;;;--------------------------------------------------------------------------