diff options
| author | Stefan Monnier | 2013-03-10 17:39:11 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-03-10 17:39:11 -0400 |
| commit | 33f5bc1cbc22e6b6b600f219aab0fdc4f987eec7 (patch) | |
| tree | 4da4f8fb1d81431132eca63872094ae839bff357 | |
| parent | d0ebc8269faa78a0f91423ec75a60a36dacf7723 (diff) | |
| download | emacs-33f5bc1cbc22e6b6b600f219aab0fdc4f987eec7.tar.gz emacs-33f5bc1cbc22e6b6b600f219aab0fdc4f987eec7.zip | |
* lisp/whitespace.el (whitespace-enable-predicate): New variable.
(whitespace-enable-predicate): Use it.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/whitespace.el | 44 |
2 files changed, 26 insertions, 21 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8d2fdc9fcd6..4add4d9383f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2013-03-10 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2013-03-10 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * whitespace.el (whitespace-enable-predicate): New variable. | ||
| 4 | (whitespace-enable-predicate): Use it. | ||
| 5 | |||
| 3 | * comint.el (comint-send-input, comint-snapshot-last-prompt) | 6 | * comint.el (comint-send-input, comint-snapshot-last-prompt) |
| 4 | (comint-output-filter, comint-update-fence): | 7 | (comint-output-filter, comint-update-fence): |
| 5 | Use with-silent-modifications. | 8 | Use with-silent-modifications. |
diff --git a/lisp/whitespace.el b/lisp/whitespace.el index ed7edbc5a68..975b89f2fc2 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el | |||
| @@ -1145,29 +1145,31 @@ See also `whitespace-style', `whitespace-newline' and | |||
| 1145 | (unless whitespace-mode | 1145 | (unless whitespace-mode |
| 1146 | (whitespace-turn-off))))))) | 1146 | (whitespace-turn-off))))))) |
| 1147 | 1147 | ||
| 1148 | (defvar whitespace-enable-predicate | ||
| 1149 | (lambda () | ||
| 1150 | (and (cond | ||
| 1151 | ((eq whitespace-global-modes t)) | ||
| 1152 | ((listp whitespace-global-modes) | ||
| 1153 | (if (eq (car-safe whitespace-global-modes) 'not) | ||
| 1154 | (not (memq major-mode (cdr whitespace-global-modes))) | ||
| 1155 | (memq major-mode whitespace-global-modes))) | ||
| 1156 | (t nil)) | ||
| 1157 | ;; ...we have a display (we're running a batch job) | ||
| 1158 | (not noninteractive) | ||
| 1159 | ;; ...the buffer is not internal (name starts with a space) | ||
| 1160 | (not (eq (aref (buffer-name) 0) ?\ )) | ||
| 1161 | ;; ...the buffer is not special (name starts with *) | ||
| 1162 | (or (not (eq (aref (buffer-name) 0) ?*)) | ||
| 1163 | ;; except the scratch buffer. | ||
| 1164 | (string= (buffer-name) "*scratch*")))) | ||
| 1165 | "Predicate to decide which buffers obey `global-whitespace-mode'. | ||
| 1166 | This function is called with no argument and should return non-nil | ||
| 1167 | if the current buffer should obey `global-whitespace-mode'. | ||
| 1168 | This variable is normally modified via `add-function'.") | ||
| 1148 | 1169 | ||
| 1149 | (defun whitespace-turn-on-if-enabled () | 1170 | (defun whitespace-turn-on-if-enabled () |
| 1150 | (when (cond | 1171 | (when (funcall whitespace-enable-predicate) |
| 1151 | ((eq whitespace-global-modes t)) | 1172 | (whitespace-turn-on))) |
| 1152 | ((listp whitespace-global-modes) | ||
| 1153 | (if (eq (car-safe whitespace-global-modes) 'not) | ||
| 1154 | (not (memq major-mode (cdr whitespace-global-modes))) | ||
| 1155 | (memq major-mode whitespace-global-modes))) | ||
| 1156 | (t nil)) | ||
| 1157 | (let (inhibit-quit) | ||
| 1158 | ;; Don't turn on whitespace mode if... | ||
| 1159 | (or | ||
| 1160 | ;; ...we don't have a display (we're running a batch job) | ||
| 1161 | noninteractive | ||
| 1162 | ;; ...or if the buffer is invisible (name starts with a space) | ||
| 1163 | (eq (aref (buffer-name) 0) ?\ ) | ||
| 1164 | ;; ...or if the buffer is temporary (name starts with *) | ||
| 1165 | (and (eq (aref (buffer-name) 0) ?*) | ||
| 1166 | ;; except the scratch buffer. | ||
| 1167 | (not (string= (buffer-name) "*scratch*"))) | ||
| 1168 | ;; Otherwise, turn on whitespace mode. | ||
| 1169 | (whitespace-turn-on))))) | ||
| 1170 | |||
| 1171 | 1173 | ||
| 1172 | ;;;###autoload | 1174 | ;;;###autoload |
| 1173 | (define-minor-mode global-whitespace-newline-mode | 1175 | (define-minor-mode global-whitespace-newline-mode |