[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/lisp ChangeLog whitespace.el
From: |
Vinicius Jose Latorre |
Subject: |
[Emacs-diffs] emacs/lisp ChangeLog whitespace.el |
Date: |
Fri, 25 Sep 2009 02:23:55 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Vinicius Jose Latorre <viniciusjl> 09/09/25 02:23:54
Modified files:
lisp : ChangeLog whitespace.el
Log message:
New version 12. Bug#4177
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/ChangeLog?cvsroot=emacs&r1=1.16257&r2=1.16258
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/whitespace.el?cvsroot=emacs&r1=1.91&r2=1.92
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.16257
retrieving revision 1.16258
diff -u -b -r1.16257 -r1.16258
--- ChangeLog 25 Sep 2009 00:32:21 -0000 1.16257
+++ ChangeLog 25 Sep 2009 02:23:51 -0000 1.16258
@@ -2,6 +2,20 @@
* progmodes/hideshow.el (hs-show-block): Run `hs-show-hook'. (Bug#4548)
+2009-09-24 Vinicius Jose Latorre <address@hidden>
+
+ * whitespace.el: Does not highlight trailing spaces While point is
+ at end of line. Does not highligt spaces at beginning of buffer
+ while point is at beginning of buffer. Does not highlight spaces
+ at end of buffer while point is at end of buffer. (Bug#4177)
+ New version 12.0.
+ (whitespace-display-mappings): Adjust initialization.
+ (whitespace-point, whitespace-font-lock-refontify): New vars.
+ (whitespace-color-on, whitespace-color-off): Adjust code.
+ (whitespace-trailing-regexp, whitespace-empty-at-bob-regexp)
+ (whitespace-empty-at-eob-regexp, whitespace-space-regexp)
+ (whitespace-tab-regexp, whitespace-post-command-hook): New funs.
+
2009-09-24 Chong Yidong <address@hidden>
* nxml/nxml-mode.el: Alias xml-mode to nxml-mode.
Index: whitespace.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/whitespace.el,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -b -r1.91 -r1.92
--- whitespace.el 16 Aug 2009 14:46:42 -0000 1.91
+++ whitespace.el 25 Sep 2009 02:23:54 -0000 1.92
@@ -6,7 +6,7 @@
;; Author: Vinicius Jose Latorre <address@hidden>
;; Maintainer: Vinicius Jose Latorre <address@hidden>
;; Keywords: data, wp
-;; Version: 11.2.2
+;; Version: 12
;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
;; This file is part of GNU Emacs.
@@ -870,8 +870,8 @@
;; Hacked from `visible-whitespace-mappings' in visws.el
(defcustom whitespace-display-mappings
'(
- (space-mark ?\ [?\xB7] [?.]) ; space - centered dot
- (space-mark ?\xA0 [?\xA4] [?_]) ; hard space - currency
+ (space-mark ?\ [?\u00B7] [?.]) ; space - centered dot
+ (space-mark ?\xA0 [?\u00A4] [?_]) ; hard space - currency
(space-mark ?\x8A0 [?\x8A4] [?_]) ; hard space - currency
(space-mark ?\x920 [?\x924] [?_]) ; hard space - currency
(space-mark ?\xE20 [?\xE24] [?_]) ; hard space - currency
@@ -879,7 +879,7 @@
;; NEWLINE is displayed using the face `whitespace-newline'
(newline-mark ?\n [?$ ?\n]) ; eol - dollar sign
;; (newline-mark ?\n [?\u21B5 ?\n] [?$ ?\n]) ; eol - downwards arrow
- ;; (newline-mark ?\n [?\xB6 ?\n] [?$ ?\n]) ; eol - pilcrow
+ ;; (newline-mark ?\n [?\u00B6 ?\n] [?$ ?\n]) ; eol - pilcrow
;; (newline-mark ?\n [?\x8AF ?\n] [?$ ?\n]) ; eol - overscore
;; (newline-mark ?\n [?\x8AC ?\n] [?$ ?\n]) ; eol - negation
;; (newline-mark ?\n [?\x8B0 ?\n] [?$ ?\n]) ; eol - grade
@@ -889,7 +889,7 @@
;; character ?\xBB at that column followed by a TAB which goes to
;; the next TAB column.
;; If this is a problem for you, please, comment the line below.
- (tab-mark ?\t [?\xBB ?\t] [?\\ ?\t]) ; tab - left quote mark
+ (tab-mark ?\t [?\u00BB ?\t] [?\\ ?\t]) ; tab - left quote mark
)
"Specify an alist of mappings for displaying characters.
@@ -1220,6 +1220,14 @@
(defvar whitespace-tab-width tab-width
"Used to save locally `tab-width' value.")
+(defvar whitespace-point (point)
+ "Used to save locally current point value.
+Used by `whitespace-trailing-regexp' function (which see).")
+
+(defvar whitespace-font-lock-refontify nil
+ "Used to save locally the font-lock refontify state.
+Used by `whitespace-post-command-hook' function (which see).")
+
;;;###autoload
(defun whitespace-toggle-options (arg)
@@ -2139,6 +2147,12 @@
(setq whitespace-font-lock t
whitespace-font-lock-keywords
(copy-sequence font-lock-keywords)))
+ ;; save current point and refontify when necessary
+ (set (make-local-variable 'whitespace-point)
+ (point))
+ (set (make-local-variable 'whitespace-font-lock-refontify)
+ nil)
+ (add-hook 'post-command-hook #'whitespace-post-command-hook nil t)
;; turn off font lock
(set (make-local-variable 'whitespace-font-lock-mode)
font-lock-mode)
@@ -2149,7 +2163,7 @@
nil
(list
;; Show SPACEs
- (list whitespace-space-regexp 1 whitespace-space t)
+ (list #'whitespace-space-regexp 1 whitespace-space t)
;; Show HARD SPACEs
(list whitespace-hspace-regexp 1 whitespace-hspace t))
t))
@@ -2158,14 +2172,14 @@
nil
(list
;; Show TABs
- (list whitespace-tab-regexp 1 whitespace-tab t))
+ (list #'whitespace-tab-regexp 1 whitespace-tab t))
t))
(when (memq 'trailing whitespace-active-style)
(font-lock-add-keywords
nil
(list
;; Show trailing blanks
- (list whitespace-trailing-regexp 1 whitespace-trailing t))
+ (list #'whitespace-trailing-regexp 1 whitespace-trailing t))
t))
(when (or (memq 'lines whitespace-active-style)
(memq 'lines-tail whitespace-active-style))
@@ -2177,7 +2191,7 @@
(format
"^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$"
whitespace-tab-width (1- whitespace-tab-width)
- (/ whitespace-line-column tab-width)
+ (/ whitespace-line-column whitespace-tab-width)
(let ((rem (% whitespace-line-column whitespace-tab-width)))
(if (zerop rem)
""
@@ -2243,14 +2257,14 @@
nil
(list
;; Show empty lines at beginning of buffer
- (list whitespace-empty-at-bob-regexp
+ (list #'whitespace-empty-at-bob-regexp
1 whitespace-empty t))
t)
(font-lock-add-keywords
nil
(list
;; Show empty lines at end of buffer
- (list whitespace-empty-at-eob-regexp
+ (list #'whitespace-empty-at-eob-regexp
1 whitespace-empty t))
t))
(cond
@@ -2287,6 +2301,7 @@
;; turn off font lock
(when (whitespace-style-face-p)
(font-lock-mode 0)
+ (remove-hook 'post-command-hook #'whitespace-post-command-hook)
(when whitespace-font-lock
(setq whitespace-font-lock nil
font-lock-keywords whitespace-font-lock-keywords))
@@ -2294,6 +2309,53 @@
(font-lock-mode whitespace-font-lock-mode)))
+(defun whitespace-trailing-regexp (limit)
+ "Match trailing spaces which does not contain the point at end of line."
+ (let ((status t))
+ (while (if (re-search-forward whitespace-trailing-regexp limit t)
+ (save-match-data
+ (= whitespace-point (match-end 1))) ;; loop if point at eol
+ (setq status nil))) ;; end of buffer
+ status))
+
+
+(defun whitespace-empty-at-bob-regexp (limit)
+ "Match spaces at beginning of buffer which does not contain the point at \
+beginning of buffer."
+ (and (/= whitespace-point 1)
+ (re-search-forward whitespace-empty-at-bob-regexp limit t)))
+
+
+(defun whitespace-empty-at-eob-regexp (limit)
+ "Match spaces at end of buffer which does not contain the point at end of \
+buffer."
+ (and (/= whitespace-point (1+ (buffer-size)))
+ (re-search-forward whitespace-empty-at-eob-regexp limit t)))
+
+
+(defun whitespace-space-regexp (limit)
+ "Match spaces."
+ (setq whitespace-font-lock-refontify t)
+ (re-search-forward whitespace-space-regexp limit t))
+
+
+(defun whitespace-tab-regexp (limit)
+ "Match tabs."
+ (setq whitespace-font-lock-refontify t)
+ (re-search-forward whitespace-tab-regexp limit t))
+
+
+(defun whitespace-post-command-hook ()
+ "Save current point into `whitespace-point' variable.
+Also refontify when necessary."
+ (setq whitespace-point (point))
+ (let ((refontify (or (eolp) ; end of line
+ (= whitespace-point 1)))) ; beginning of buffer
+ (when (or whitespace-font-lock-refontify refontify)
+ (setq whitespace-font-lock-refontify refontify)
+ (jit-lock-refontify))))
+
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Hacked from visws.el (Miles Bader <address@hidden>)
- [Emacs-diffs] emacs/lisp ChangeLog whitespace.el,
Vinicius Jose Latorre <=