From b7fc31ec024ef70d48888a80db951cd23a36e457 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 3 Aug 2017 10:51:58 +0100 Subject: [PATCH] el/dot-emacs.el: Move `mdw-compile' into its own section. I'll add more stuff to this currently rather small section soon. --- el/dot-emacs.el | 103 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 63f6e9d..bd7541a 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -293,56 +293,6 @@ 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) @@ -565,6 +515,59 @@ Pretend they don't exist. They might be on other display devices." (ad-set-arg 2 nil)) ;;;-------------------------------------------------------------------------- +;;; Improved compilation machinery. + +;; Uprated version of M-x compile. + +(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))) + +;;;-------------------------------------------------------------------------- ;;; Mail and news hacking. (define-derived-mode mdwmail-mode mail-mode "[mdw] mail" -- 2.11.0