[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/whitespace.el,v
From: |
Vinicius Jose Latorre |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/whitespace.el,v |
Date: |
Sat, 06 Sep 2008 00:19:36 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Vinicius Jose Latorre <viniciusjl> 08/09/06 00:19:34
Index: whitespace.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/whitespace.el,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- whitespace.el 6 Aug 2008 03:35:04 -0000 1.84
+++ whitespace.el 6 Sep 2008 00:19:34 -0000 1.85
@@ -6,7 +6,7 @@
;; Author: Vinicius Jose Latorre <address@hidden>
;; Maintainer: Vinicius Jose Latorre <address@hidden>
;; Keywords: data, wp
-;; Version: 11.2
+;; Version: 11.2.1
;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
;; This file is part of GNU Emacs.
@@ -989,6 +989,10 @@
abort-on-bogus abort if there is any bogus whitespace and the
buffer is written or killed.
+ warn-read-only give a warning if `cleanup' or `auto-cleanup'
+ is included in `whitespace-action' and the
+ buffer is read-only.
+
Any other value is treated as nil."
:type '(choice :tag "Actions"
(const :tag "None" nil)
@@ -997,7 +1001,8 @@
(const :tag "Cleanup When On" cleanup)
(const :tag "Report On Bogus" report-on-bogus)
(const :tag "Auto Cleanup" auto-cleanup)
- (const :tag "Abort On Bogus" abort-on-bogus))))
+ (const :tag "Abort On Bogus" abort-on-bogus)
+ (const :tag "Warn Read-Only" warn-read-only))))
:group 'whitespace)
@@ -1428,18 +1433,23 @@
See `whitespace-style', `indent-tabs-mode' and `tab-width' for
documentation."
- (interactive "@*")
- (if (and (or transient-mark-mode
+ (interactive "@")
+ (cond
+ ;; read-only buffer
+ (buffer-read-only
+ (whitespace-warn-read-only "cleanup"))
+ ;; region active
+ ((and (or transient-mark-mode
current-prefix-arg)
mark-active)
- ;; region active
;; PROBLEMs 1 and 2 are not handled in region
;; PROBLEM 3: 8 or more SPACEs at bol
;; PROBLEM 4: SPACEs before TAB
;; PROBLEM 5: SPACEs or TABs at eol
;; PROBLEM 6: 8 or more SPACEs after TAB
- (whitespace-cleanup-region (region-beginning) (region-end))
+ (whitespace-cleanup-region (region-beginning) (region-end)))
;; whole buffer
+ (t
(save-excursion
(save-match-data
;; PROBLEM 1: empty lines at bob
@@ -1458,7 +1468,7 @@
;; PROBLEM 4: SPACEs before TAB
;; PROBLEM 5: SPACEs or TABs at eol
;; PROBLEM 6: 8 or more SPACEs after TAB
- (whitespace-cleanup-region (point-min) (point-max))))
+ (whitespace-cleanup-region (point-min) (point-max)))))
;;;###autoload
@@ -1501,7 +1511,11 @@
See `whitespace-style', `indent-tabs-mode' and `tab-width' for
documentation."
- (interactive "@*r")
+ (interactive "@r")
+ (if buffer-read-only
+ ;; read-only buffer
+ (whitespace-warn-read-only "cleanup region")
+ ;; non-read-only buffer
(let ((rstart (min start end))
(rend (copy-marker (max start end)))
(indent-tabs-mode whitespace-indent-tabs-mode)
@@ -1513,8 +1527,8 @@
;; PROBLEM 1: 8 or more SPACEs at bol
(cond
;; ACTION: replace 8 or more SPACEs at bol by TABs, if
- ;; `indent-tabs-mode' is non-nil; otherwise, replace TABs by
- ;; SPACEs.
+ ;; `indent-tabs-mode' is non-nil; otherwise, replace TABs
+ ;; by SPACEs.
((memq 'indentation whitespace-style)
(let ((regexp (whitespace-indentation-regexp)))
(goto-char rstart)
@@ -1543,8 +1557,8 @@
;; PROBLEM 4: 8 or more SPACEs after TAB
(cond
;; ACTION: replace 8 or more SPACEs by TABs, if
- ;; `indent-tabs-mode' is non-nil; otherwise, replace TABs by
- ;; SPACEs.
+ ;; `indent-tabs-mode' is non-nil; otherwise, replace TABs
+ ;; by SPACEs.
((memq 'space-after-tab whitespace-style)
(whitespace-replace-action
(if whitespace-indent-tabs-mode 'tabify 'untabify)
@@ -1562,8 +1576,8 @@
;; PROBLEM 2: SPACEs before TAB
(cond
;; ACTION: replace SPACEs before TAB by TABs, if
- ;; `indent-tabs-mode' is non-nil; otherwise, replace TABs by
- ;; SPACEs.
+ ;; `indent-tabs-mode' is non-nil; otherwise, replace TABs
+ ;; by SPACEs.
((memq 'space-before-tab whitespace-style)
(whitespace-replace-action
(if whitespace-indent-tabs-mode 'tabify 'untabify)
@@ -1579,7 +1593,7 @@
(whitespace-replace-action
'untabify rstart rend
whitespace-space-before-tab-regexp 2)))))
- (set-marker rend nil))) ; point marker to nowhere
+ (set-marker rend nil)))) ; point marker to nowhere
(defun whitespace-replace-action (action rstart rend regexp index)
@@ -2405,6 +2419,12 @@
nil)))
+(defun whitespace-warn-read-only (msg)
+ "Warn if buffer is read-only."
+ (when (memq 'warn-read-only whitespace-action)
+ (message "Can't %s: %s is read-only" msg (buffer-name))))
+
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- [Emacs-diffs] Changes to emacs/lisp/whitespace.el,v,
Vinicius Jose Latorre <=