aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinicius Jose Latorre2008-10-02 00:49:49 +0000
committerVinicius Jose Latorre2008-10-02 00:49:49 +0000
commit97f6e1ad87856872182b653d96c555cabee39cdc (patch)
treefa4e2ac18429b6b58250df7b6c1e08e5b7977b11
parent8ed4a859771541b536e093af5f17d1174be0ac01 (diff)
downloademacs-97f6e1ad87856872182b653d96c555cabee39cdc.tar.gz
emacs-97f6e1ad87856872182b653d96c555cabee39cdc.zip
Eliminate whitespace-kill-buffer-hook functionality.
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/whitespace.el63
2 files changed, 29 insertions, 46 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6eccc98dbe0..2424124ba32 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12008-10-01 Vinicius Jose Latorre <viniciusjl@ig.com.br>
2
3 * whitespace.el: Eliminate whitespace-kill-buffer-hook functionality,
4 that is, to take some action when a buffer is killed. Suggested by
5 Stefan Monnier <monnier@iro.umontreal.ca>. Doc fix. New version
6 11.2.2.
7 (whitespace-action): Docstring and :type fix.
8 (whitespace-turn-on, whitespace-turn-off, whitespace-warn-read-only):
9 Code fix.
10 (whitespace-add-local-hook, whitespace-remove-local-hook)
11 (whitespace-kill-buffer-hook, whitespace-action): Fun eliminated.
12
12008-10-01 Magnus Henoch <mange@freemail.hu> 132008-10-01 Magnus Henoch <mange@freemail.hu>
2 14
3 * net/tls.el (open-tls-stream): Show the actual command being 15 * net/tls.el (open-tls-stream): Show the actual command being
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 56d4e58f138..534e4436062 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -6,7 +6,7 @@
6;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> 6;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
7;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> 7;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
8;; Keywords: data, wp 8;; Keywords: data, wp
9;; Version: 11.2.1 9;; Version: 11.2.2
10;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre 10;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
11 11
12;; This file is part of GNU Emacs. 12;; This file is part of GNU Emacs.
@@ -302,7 +302,7 @@
302;; turned on. 302;; turned on.
303;; 303;;
304;; `whitespace-action' Specify which action is taken when a 304;; `whitespace-action' Specify which action is taken when a
305;; buffer is visited, killed or written. 305;; buffer is visited or written.
306;; 306;;
307;; 307;;
308;; Acknowledgements 308;; Acknowledgements
@@ -316,8 +316,8 @@
316;; `indent-tabs-mode' usage suggestion. 316;; `indent-tabs-mode' usage suggestion.
317;; 317;;
318;; Thanks to Eric Cooper <ecc@cmu.edu> for the suggestion to have hook 318;; Thanks to Eric Cooper <ecc@cmu.edu> for the suggestion to have hook
319;; actions when buffer is written or killed as the original whitespace 319;; actions when buffer is written as the original whitespace package
320;; package had. 320;; had.
321;; 321;;
322;; Thanks to nschum (EmacsWiki) for the idea about highlight "long" 322;; Thanks to nschum (EmacsWiki) for the idea about highlight "long"
323;; lines tail. See EightyColumnRule (EmacsWiki). 323;; lines tail. See EightyColumnRule (EmacsWiki).
@@ -967,7 +967,7 @@ C++ modes only."
967 967
968 968
969(defcustom whitespace-action nil 969(defcustom whitespace-action nil
970 "*Specify which action is taken when a buffer is visited, killed or written. 970 "*Specify which action is taken when a buffer is visited or written.
971 971
972It's a list containing some or all of the following values: 972It's a list containing some or all of the following values:
973 973
@@ -982,14 +982,14 @@ It's a list containing some or all of the following values:
982 when local whitespace is turned on. 982 when local whitespace is turned on.
983 983
984 auto-cleanup cleanup any bogus whitespace when buffer is 984 auto-cleanup cleanup any bogus whitespace when buffer is
985 written or killed. 985 written.
986 See `whitespace-cleanup' and 986 See `whitespace-cleanup' and
987 `whitespace-cleanup-region'. 987 `whitespace-cleanup-region'.
988 988
989 abort-on-bogus abort if there is any bogus whitespace and the 989 abort-on-bogus abort if there is any bogus whitespace and the
990 buffer is written or killed. 990 buffer is written.
991 991
992 warn-read-only give a warning if `cleanup' or `auto-cleanup' 992 warn-if-read-only give a warning if `cleanup' or `auto-cleanup'
993 is included in `whitespace-action' and the 993 is included in `whitespace-action' and the
994 buffer is read-only. 994 buffer is read-only.
995 995
@@ -1002,7 +1002,7 @@ Any other value is treated as nil."
1002 (const :tag "Report On Bogus" report-on-bogus) 1002 (const :tag "Report On Bogus" report-on-bogus)
1003 (const :tag "Auto Cleanup" auto-cleanup) 1003 (const :tag "Auto Cleanup" auto-cleanup)
1004 (const :tag "Abort On Bogus" abort-on-bogus) 1004 (const :tag "Abort On Bogus" abort-on-bogus)
1005 (const :tag "Warn Read-Only" warn-read-only)))) 1005 (const :tag "Warn If Read-Only" warn-if-read-only))))
1006 :group 'whitespace) 1006 :group 'whitespace)
1007 1007
1008 1008
@@ -2083,7 +2083,7 @@ resultant list will be returned."
2083(defun whitespace-turn-on () 2083(defun whitespace-turn-on ()
2084 "Turn on whitespace visualization." 2084 "Turn on whitespace visualization."
2085 ;; prepare local hooks 2085 ;; prepare local hooks
2086 (whitespace-add-local-hook) 2086 (add-hook 'write-file-functions 'whitespace-write-file-hook nil t)
2087 ;; create whitespace local buffer environment 2087 ;; create whitespace local buffer environment
2088 (set (make-local-variable 'whitespace-font-lock-mode) nil) 2088 (set (make-local-variable 'whitespace-font-lock-mode) nil)
2089 (set (make-local-variable 'whitespace-font-lock) nil) 2089 (set (make-local-variable 'whitespace-font-lock) nil)
@@ -2106,7 +2106,7 @@ resultant list will be returned."
2106 2106
2107(defun whitespace-turn-off () 2107(defun whitespace-turn-off ()
2108 "Turn off whitespace visualization." 2108 "Turn off whitespace visualization."
2109 (whitespace-remove-local-hook) 2109 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
2110 (when whitespace-active-style 2110 (when whitespace-active-style
2111 (whitespace-color-off) 2111 (whitespace-color-off)
2112 (whitespace-display-char-off))) 2112 (whitespace-display-char-off)))
@@ -2379,50 +2379,21 @@ resultant list will be returned."
2379 (whitespace-report nil t)))) 2379 (whitespace-report nil t))))
2380 2380
2381 2381
2382(defun whitespace-add-local-hook ()
2383 "Add some whitespace hooks locally."
2384 (add-hook 'write-file-functions 'whitespace-write-file-hook nil t)
2385 (add-hook 'kill-buffer-hook 'whitespace-kill-buffer-hook nil t))
2386
2387
2388(defun whitespace-remove-local-hook ()
2389 "Remove some whitespace hooks locally."
2390 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
2391 (remove-hook 'kill-buffer-hook 'whitespace-kill-buffer-hook t))
2392
2393
2394(defun whitespace-write-file-hook () 2382(defun whitespace-write-file-hook ()
2395 "Action to be taken when buffer is written. 2383 "Action to be taken when buffer is written.
2396It should be added buffer-locally to `write-file-functions'." 2384It should be added buffer-locally to `write-file-functions'."
2397 (when (whitespace-action)
2398 (error "Abort write due to whitespace problems in %s"
2399 (buffer-name)))
2400 nil) ; continue hook processing
2401
2402
2403(defun whitespace-kill-buffer-hook ()
2404 "Action to be taken when buffer is killed.
2405It should be added buffer-locally to `kill-buffer-hook'."
2406 (whitespace-action t)
2407 nil) ; continue hook processing
2408
2409
2410(defun whitespace-action (&optional is-killing-buffer)
2411 "Action to be taken when buffer is killed or written.
2412Return t when the action should be aborted."
2413 (cond ((memq 'auto-cleanup whitespace-action) 2385 (cond ((memq 'auto-cleanup whitespace-action)
2414 (unless is-killing-buffer 2386 (whitespace-cleanup))
2415 (whitespace-cleanup))
2416 nil)
2417 ((memq 'abort-on-bogus whitespace-action) 2387 ((memq 'abort-on-bogus whitespace-action)
2418 (whitespace-report nil t)) 2388 (when (whitespace-report nil t)
2419 (t 2389 (error "Abort write due to whitespace problems in %s"
2420 nil))) 2390 (buffer-name)))))
2391 nil) ; continue hook processing
2421 2392
2422 2393
2423(defun whitespace-warn-read-only (msg) 2394(defun whitespace-warn-read-only (msg)
2424 "Warn if buffer is read-only." 2395 "Warn if buffer is read-only."
2425 (when (memq 'warn-read-only whitespace-action) 2396 (when (memq 'warn-if-read-only whitespace-action)
2426 (message "Can't %s: %s is read-only" msg (buffer-name)))) 2397 (message "Can't %s: %s is read-only" msg (buffer-name))))
2427 2398
2428 2399