GNU bug report logs - #13837
24.2; Make it possible to turn whitespace-mode only when there are no existing problems

Previous Next

Package: emacs;

Reported by: Reuben Thomas <rrt <at> sc3d.org>

Date: Wed, 27 Feb 2013 21:45:02 UTC

Severity: wishlist

Found in version 24.2

Fixed in version 25.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13837 in the body.
You can then email your comments to 13837 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Wed, 27 Feb 2013 21:45:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Reuben Thomas <rrt <at> sc3d.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 27 Feb 2013 21:45:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2; Make it possible to turn whitespace-mode only when there are no
	existing problems
Date: Wed, 27 Feb 2013 21:41:41 +0000
I like global-whitespace-mode, but it has a downside: it keeps
activating in files that have whitespace problems, but which don't
belong to me, so I don't want to fix them. Typically I want to make a
small edit to someone else's code, and they, entirely reasonably, don't
want a big diff.

The following code implements a solution to that, which is to check if
the buffer is whitespace-clean before activating whitespace-mode.

Unfortunately, my current solution is non-optional: it requires
modifying whitespace-turn-on-if-enabled. This could be fixed, for
example by adding a preference.

The other part of the solution is easier to integrate: I've factored out
part of whitespace-report-region into whitespace-test-region, in a way
which is easy to use to implement whitespace-report-region.

If maintainers are interested in adding this feature, I'd be happy to
take guidance on how to modify my code into a patch (currently it just
sits in my .emacs).

;; Make whitespace-turn-on-if-enabled to turn on only if no
;; whitespace problems in current buffer.
(require 'whitespace)
(defun whitespace-test-region (start end)
  "Find whether there are whitespace problems in a region.

Return nil if there is no whitespace problem; otherwise, return
non-nil.

A whitespace problem is one of the following:

* If `indent-tabs-mode' is non-nil:
   empty		1. empty lines at beginning of buffer.
   empty		2. empty lines at end of buffer.
   trailing		3. SPACEs or TABs at end of line.
   indentation		4. 8 or more SPACEs at beginning of line.
   space-before-tab	5. SPACEs before TAB.
   space-after-tab	6. 8 or more SPACEs after TAB.

* If `indent-tabs-mode' is nil:
   empty		1. empty lines at beginning of buffer.
   empty		2. empty lines at end of buffer.
   trailing		3. SPACEs or TABs at end of line.
   indentation		4. TABS at beginning of line.
   space-before-tab	5. SPACEs before TAB.
   space-after-tab	6. 8 or more SPACEs after TAB.

See `whitespace-style' for documentation.
See also `whitespace-cleanup' and `whitespace-cleanup-region' for
cleaning up these problems."
  (save-excursion
    (save-match-data                ;FIXME: Why?
      (let* ((has-bogus nil)
             (rstart    (min start end))
             (rend      (max start end))
             (bogus-list
              (mapcar
               #'(lambda (option)
                   (when force
                     (add-to-list 'whitespace-style (car option)))
                   (goto-char rstart)
                   (let ((regexp
                          (cond
                           ((eq (car option) 'indentation)
                            (whitespace-indentation-regexp))
                           ((eq (car option) 'indentation::tab)
                            (whitespace-indentation-regexp 'tab))
                           ((eq (car option) 'indentation::space)
                            (whitespace-indentation-regexp 'space))
                           ((eq (car option) 'space-after-tab)
                            (whitespace-space-after-tab-regexp))
                           ((eq (car option) 'space-after-tab::tab)
                            (whitespace-space-after-tab-regexp 'tab))
                           ((eq (car option) 'space-after-tab::space)
                            (whitespace-space-after-tab-regexp 'space))
                           (t
                            (cdr option)))))
                     (and (re-search-forward regexp rend t)
                          (setq has-bogus t))))
               whitespace-report-list)))
        has-bogus))))

(defun whitespace-turn-on-if-enabled ()
  (when (cond
         ((eq whitespace-global-modes t))
         ((listp whitespace-global-modes)
          (if (eq (car-safe whitespace-global-modes) 'not)
              (not (memq major-mode (cdr whitespace-global-modes)))
            (memq major-mode whitespace-global-modes)))
         (t nil))
    (let (inhibit-quit)
      ;; Don't turn on whitespace mode if...
      (or
       ;; ...we don't have a display (we're running a batch job)
       noninteractive
       ;; ...or if the buffer is invisible (name starts with a space)
       (eq (aref (buffer-name) 0) ?\ )
       ;; ...or if the buffer is temporary (name starts with *)
       (and (eq (aref (buffer-name) 0) ?*)
            ;; except the scratch buffer.
            (not (string= (buffer-name) "*scratch*")))
       ;; Otherwise, turn on whitespace mode.
       (whitespace-find-problems-region (point-min) (point-max))
       (whitespace-turn-on)))))


In GNU Emacs 24.2.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.13)
 of 2012-12-13 on komainu, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11300000
Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var/lib' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.2/site-lisp:/usr/share/emacs/site-lisp'
 '--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes'
 '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars'
 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector
 --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall'
 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: en_GB.UTF-8
  value of $LC_NUMERIC: en_GB.UTF-8
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  recentf-mode: t
  show-paren-mode: t
  server-mode: t
  savehist-mode: t
  minibuffer-electric-default-mode: t
  iswitchb-mode: t
  icomplete-mode: t
  global-whitespace-mode: t
  global-auto-revert-mode: t
  dtrt-indent-mode: t
  desktop-save-mode: t
  TeX-PDF-mode: t
  TeX-source-correlate-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
SPC SPC C-x C-s C-x k <return> C-x k <return> <down-mouse-1> 
<mouse-1> C-x b <return> C-x b C-s C-a C-] C-] C-] 
C-x b f u n s <return> C-a C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-SPC 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-p C-g C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-n <up> <up> <down> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<left> <left> <left> <left> <left> <left> <left> <M-backspace> 
M a k e C-x C-s C-a C-SPC C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-p M-w M-x r e p o r t - b <backspace> e m a c s - 
b u g <return>

Recent messages:
Saving file /home/rrt/Software/hacked/cw/bar.c...
Wrote /home/rrt/Software/hacked/cw/bar.c
Quit
call-interactively: No recursive edit is in progress [2 times]
Mark set
Quit
Saving file /home/rrt/.emacs.d/funs.el...
Wrote /home/rrt/.emacs.d/funs.el
Mark activated
Saved text from ";; Make whitespace-turn-on-if-enabled to"

Load-path shadows:
/home/rrt/local/share/emacs/site-lisp/browse-kill-ring hides /usr/share/emacs24/site-lisp/emacs-goodies-el/browse-kill-ring
/home/rrt/local/share/emacs/site-lisp/dict hides /usr/share/emacs24/site-lisp/emacs-goodies-el/dict
/home/rrt/.emacs.d/elpa/dictionary-1.8.7/dictionary-init hides /usr/share/emacs24/site-lisp/dictionary-el/dictionary-init
/home/rrt/.emacs.d/elpa/dictionary-1.8.7/dictionary hides /usr/share/emacs24/site-lisp/dictionary-el/dictionary
/home/rrt/.emacs.d/elpa/dictionary-1.8.7/link hides /usr/share/emacs24/site-lisp/dictionary-el/link
/home/rrt/.emacs.d/elpa/dictionary-1.8.7/connection hides /usr/share/emacs24/site-lisp/dictionary-el/connection
/usr/share/emacs24/site-lisp/auctex/tex-style hides /usr/share/emacs/site-lisp/auctex/tex-style
/usr/share/emacs24/site-lisp/auctex/tex-mik hides /usr/share/emacs/site-lisp/auctex/tex-mik
/usr/share/emacs24/site-lisp/auctex/multi-prompt hides /usr/share/emacs/site-lisp/auctex/multi-prompt
/usr/share/emacs24/site-lisp/auctex/tex-jp hides /usr/share/emacs/site-lisp/auctex/tex-jp
/usr/share/emacs24/site-lisp/auctex/tex-info hides /usr/share/emacs/site-lisp/auctex/tex-info
/usr/share/emacs24/site-lisp/auctex/plain-tex hides /usr/share/emacs/site-lisp/auctex/plain-tex
/usr/share/emacs24/site-lisp/auctex/latex hides /usr/share/emacs/site-lisp/auctex/latex
/usr/share/emacs24/site-lisp/auctex/preview hides /usr/share/emacs/site-lisp/auctex/preview
/usr/share/emacs24/site-lisp/auctex/tex hides /usr/share/emacs/site-lisp/auctex/tex
/usr/share/emacs24/site-lisp/auctex/texmathp hides /usr/share/emacs/site-lisp/auctex/texmathp
/usr/share/emacs24/site-lisp/auctex/context-nl hides /usr/share/emacs/site-lisp/auctex/context-nl
/usr/share/emacs24/site-lisp/auctex/tex-font hides /usr/share/emacs/site-lisp/auctex/tex-font
/usr/share/emacs24/site-lisp/auctex/toolbar-x hides /usr/share/emacs/site-lisp/auctex/toolbar-x
/usr/share/emacs24/site-lisp/auctex/tex-buf hides /usr/share/emacs/site-lisp/auctex/tex-buf
/usr/share/emacs24/site-lisp/auctex/bib-cite hides /usr/share/emacs/site-lisp/auctex/bib-cite
/usr/share/emacs24/site-lisp/auctex/context-en hides /usr/share/emacs/site-lisp/auctex/context-en
/usr/share/emacs24/site-lisp/auctex/tex-fold hides /usr/share/emacs/site-lisp/auctex/tex-fold
/usr/share/emacs24/site-lisp/auctex/tex-bar hides /usr/share/emacs/site-lisp/auctex/tex-bar
/usr/share/emacs24/site-lisp/auctex/context hides /usr/share/emacs/site-lisp/auctex/context
/usr/share/emacs24/site-lisp/auctex/prv-emacs hides /usr/share/emacs/site-lisp/auctex/prv-emacs
/usr/share/emacs24/site-lisp/auctex/font-latex hides /usr/share/emacs/site-lisp/auctex/font-latex
/usr/share/emacs/site-lisp/golang-mode/go-mode-load hides /usr/share/emacs/24.2/site-lisp/golang-mode/go-mode-load
/usr/share/emacs/site-lisp/golang-mode/go-mode hides /usr/share/emacs/24.2/site-lisp/golang-mode/go-mode
/usr/share/emacs/24.2/site-lisp/cmake-data/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode
/usr/share/emacs/24.2/site-lisp/cdargs hides /usr/share/emacs/site-lisp/cdargs
/usr/share/emacs/site-lisp/rst hides /usr/share/emacs/24.2/lisp/textmodes/rst
/usr/share/emacs24/site-lisp/dictionaries-common/ispell hides /usr/share/emacs/24.2/lisp/textmodes/ispell
/usr/share/emacs24/site-lisp/dictionaries-common/flyspell hides /usr/share/emacs/24.2/lisp/textmodes/flyspell
/home/rrt/local/share/emacs/site-lisp/flymake hides /usr/share/emacs/24.2/lisp/progmodes/flymake

Features:
(shadow sort mail-extr emacsbug message format-spec rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils find-func
help-mode view cperl-mode sh-script executable nroff-mode conf-mode
newcomment misearch multi-isearch jka-compr rect todoo noutline outline
lua-mode autoconf autoconf-mode make-mode vc-git cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
flymake compile comint ansi-color ring face-remap flyspell ispell
smart-quotes auto-dictionary-autoloads c-eldoc-autoloads
dictionary-autoloads diff-git-autoloads dired-isearch-autoloads
full-ack-autoloads guess-style-autoloads kill-ring-search-autoloads
magit-autoloads mv-shell-autoloads tumble-autoloads
http-post-simple-autoloads package tabulated-list completing-help
recentf tree-widget wid-edit uniquify paren server savehist
minibuf-eldef iswitchb icomplete whitespace autorevert dtrt-indent
desktop cus-start cus-load ropemacs pymacs warnings url-util url-parse
auth-source eieio byte-opt bytecomp byte-compile cconv macroexp
gnus-util password-cache url-vars mm-util mail-prsvr tex dbus xml
regexp-opt remember user-site-loaddefs advice advice-preload yasnippet
help-fns derived edmacro kmacro easymenu assoc cl muse-autoloads
go-mode-load emacs-goodies-el emacs-goodies-custom
emacs-goodies-loaddefs easy-mmode preview-latex tex-site auto-loads
time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image fringe lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

-- 
http://rrt.sc3d.org/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Thu, 28 Feb 2013 02:03:01 GMT) Full text and rfc822 format available.

Message #8 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: 13837 <at> debbugs.gnu.org
Subject: Update to code
Date: Thu, 28 Feb 2013 02:00:41 +0000
Apologies, the original code posted contained two lines which
shouldn't've been there, mentioning a non-existent "force" parameter
to whitespace-test-region. The function should read:

(defun whitespace-test-region (start end)
  "Find whether there are whitespace problems in a region.

Return nil if there is no whitespace problem; otherwise, return
non-nil.

A whitespace problem is one of the following:

* If `indent-tabs-mode' is non-nil:
   empty        1. empty lines at beginning of buffer.
   empty        2. empty lines at end of buffer.
   trailing        3. SPACEs or TABs at end of line.
   indentation        4. 8 or more SPACEs at beginning of line.
   space-before-tab    5. SPACEs before TAB.
   space-after-tab    6. 8 or more SPACEs after TAB.

* If `indent-tabs-mode' is nil:
   empty        1. empty lines at beginning of buffer.
   empty        2. empty lines at end of buffer.
   trailing        3. SPACEs or TABs at end of line.
   indentation        4. TABS at beginning of line.
   space-before-tab    5. SPACEs before TAB.
   space-after-tab    6. 8 or more SPACEs after TAB.

See `whitespace-style' for documentation.
See also `whitespace-cleanup' and `whitespace-cleanup-region' for
cleaning up these problems."
  (save-excursion
    (save-match-data                ;FIXME: Why?
      (let* ((has-bogus nil)
             (rstart    (min start end))
             (rend      (max start end))
             (bogus-list
              (mapcar
               #'(lambda (option)
                   (goto-char rstart)
                   (let ((regexp
                          (cond
                           ((eq (car option) 'indentation)
                            (whitespace-indentation-regexp))
                           ((eq (car option) 'indentation::tab)
                            (whitespace-indentation-regexp 'tab))
                           ((eq (car option) 'indentation::space)
                            (whitespace-indentation-regexp 'space))
                           ((eq (car option) 'space-after-tab)
                            (whitespace-space-after-tab-regexp))
                           ((eq (car option) 'space-after-tab::tab)
                            (whitespace-space-after-tab-regexp 'tab))
                           ((eq (car option) 'space-after-tab::space)
                            (whitespace-space-after-tab-regexp 'space))
                           (t
                            (cdr option)))))
                     (and (re-search-forward regexp rend t)
                          (setq has-bogus t))))
               whitespace-report-list)))
        has-bogus))))

--
http://rrt.sc3d.org




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Thu, 28 Feb 2013 16:26:02 GMT) Full text and rfc822 format available.

Message #11 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2;
	Make it possible to turn whitespace-mode only when there are no
	existing problems
Date: Thu, 28 Feb 2013 11:23:33 -0500
> Unfortunately, my current solution is non-optional: it requires
> modifying whitespace-turn-on-if-enabled.  This could be fixed, for
> example by adding a preference.

Indeed.  I suggest to add a whitespace-enable-predicate hook.

Then you can do

  (defun whitespace-check-cleanliness ()
    (not (whitespace-test-region (point-min) (point-max))))
  (add-function :after-while whitespace-enable-predicate
                #'whitespace-check-cleanliness)

> If maintainers are interested in adding this feature, I'd be happy to
> take guidance on how to modify my code into a patch (currently it just
> sits in my .emacs).

You can start with the patch below, and refactor the
whitespace-report-region so as to provide whitespace-test-region.
Your .emacs can then be reduced to the above 4 lines, and if you add the
whitespace-check-cleanliness function to whitespace.el that gets reduced
to just 2 lines.


        Stefan


=== modified file 'lisp/whitespace.el'
--- lisp/whitespace.el	2013-01-11 23:08:55 +0000
+++ lisp/whitespace.el	2013-02-28 16:19:01 +0000
@@ -1145,29 +1145,31 @@
 	(unless whitespace-mode
 	  (whitespace-turn-off)))))))
 
-
-(defun whitespace-turn-on-if-enabled ()
-  (when (cond
+(defvar whitespace-enable-predicate
+  (lambda ()
+    (and (cond
 	 ((eq whitespace-global-modes t))
 	 ((listp whitespace-global-modes)
 	  (if (eq (car-safe whitespace-global-modes) 'not)
 	      (not (memq major-mode (cdr whitespace-global-modes)))
 	    (memq major-mode whitespace-global-modes)))
 	 (t nil))
-    (let (inhibit-quit)
-      ;; Don't turn on whitespace mode if...
-      (or
-       ;; ...we don't have a display (we're running a batch job)
-       noninteractive
-       ;; ...or if the buffer is invisible (name starts with a space)
-       (eq (aref (buffer-name) 0) ?\ )
-       ;; ...or if the buffer is temporary (name starts with *)
-       (and (eq (aref (buffer-name) 0) ?*)
+         ;; ...we have a display (we're running a batch job)
+         (not noninteractive)
+         ;; ...the buffer is not internal (name starts with a space)
+         (not (eq (aref (buffer-name) 0) ?\ ))
+         ;; ...the buffer is not special (name starts with *)
+         (or (not (eq (aref (buffer-name) 0) ?*))
 	    ;; except the scratch buffer.
-	    (not (string= (buffer-name) "*scratch*")))
-       ;; Otherwise, turn on whitespace mode.
-       (whitespace-turn-on)))))
+             (string= (buffer-name) "*scratch*"))))
+  "Predicate to decide which buffers obey `global-whitespace-mode'.
+This function is called with no argument and should return non-nil
+if the current buffer should obey `global-whitespace-mode'.
+This variable is normally modified via `add-function'.")
 
+(defun whitespace-turn-on-if-enabled ()
+  (when (funcall whitespace-enable-predicate)
+    (whitespace-turn-on)))
 
 ;;;###autoload
 (define-minor-mode global-whitespace-newline-mode





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Thu, 28 Feb 2013 16:35:01 GMT) Full text and rfc822 format available.

Message #14 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2;
	Make it possible to turn whitespace-mode only when there are no
	existing problems
Date: Thu, 28 Feb 2013 11:32:21 -0500
>   (add-function :after-while whitespace-enable-predicate
>                 #'whitespace-check-cleanliness)

Sorry, this should be

   (add-function :after-while (default-value 'whitespace-enable-predicate)
                 #'whitespace-check-cleanliness)


-- Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Fri, 01 Mar 2013 22:05:01 GMT) Full text and rfc822 format available.

Message #17 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
	when there are no existing problems
Date: Fri, 1 Mar 2013 22:02:00 +0000
On 28 February 2013 16:32, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>>   (add-function :after-while whitespace-enable-predicate
>>                 #'whitespace-check-cleanliness)
>
> Sorry, this should be
>
>    (add-function :after-while (default-value 'whitespace-enable-predicate)
>                  #'whitespace-check-cleanliness)

Emacs 24 doesn't seem to have add-function; copying nadvice.el into my
site-lisp directory seems to take me down the gv-ref rabbit hole (in
the sense that I tried installing it into Emacs 24 before and found I
was just copying more and more stuff from master). Do you have an
old-fashioned alternative? (Sorry, I only tried advice for the first
time, while trying to do the above hack more neatly.)

-- 
http://rrt.sc3d.org




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Fri, 01 Mar 2013 22:24:01 GMT) Full text and rfc822 format available.

Message #20 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
	when there are no existing problems
Date: Fri, 1 Mar 2013 22:21:41 +0000
On 28 February 2013 16:23, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>
> You can … refactor the
> whitespace-report-region so as to provide whitespace-test-region.

Here's an attempt at that:

(defun whitespace-test-region (start end)
  "Find whether there are whitespace problems in a region.

Return a list of whitespace problems (hence, nil if there is no
whitespace problem).

A whitespace problem is one of the following:

* If `indent-tabs-mode' is non-nil:
   empty        1. empty lines at beginning of buffer.
   empty        2. empty lines at end of buffer.
   trailing        3. SPACEs or TABs at end of line.
   indentation        4. 8 or more SPACEs at beginning of line.
   space-before-tab    5. SPACEs before TAB.
   space-after-tab    6. 8 or more SPACEs after TAB.

* If `indent-tabs-mode' is nil:
   empty        1. empty lines at beginning of buffer.
   empty        2. empty lines at end of buffer.
   trailing        3. SPACEs or TABs at end of line.
   indentation        4. TABS at beginning of line.
   space-before-tab    5. SPACEs before TAB.
   space-after-tab    6. 8 or more SPACEs after TAB.

See `whitespace-style' for documentation.
See also `whitespace-cleanup' and `whitespace-cleanup-region' for
cleaning up these problems."
  (save-excursion
    (save-match-data                ;FIXME: Why?
      (let* ((has-bogus nil)
             (rstart    (min start end))
             (rend      (max start end))
             (bogus-list
              (mapcar
               #'(lambda (option)
                   (goto-char rstart)
                   (let ((regexp
                          (cond
                           ((eq (car option) 'indentation)
                            (whitespace-indentation-regexp))
                           ((eq (car option) 'indentation::tab)
                            (whitespace-indentation-regexp 'tab))
                           ((eq (car option) 'indentation::space)
                            (whitespace-indentation-regexp 'space))
                           ((eq (car option) 'space-after-tab)
                            (whitespace-space-after-tab-regexp))
                           ((eq (car option) 'space-after-tab::tab)
                            (whitespace-space-after-tab-regexp 'tab))
                           ((eq (car option) 'space-after-tab::space)
                            (whitespace-space-after-tab-regexp 'space))
                           (t
                            (cdr option)))))
                     (and (re-search-forward regexp rend t)
                          t)))
               whitespace-report-list)))
        bogus-list))))

(defun whitespace-report-region (start end &optional force report-if-bogus)
  "Report some whitespace problems in a region.

Return nil if there is no whitespace problem; otherwise, return
non-nil.

If FORCE is non-nil or \\[universal-argument] was pressed just
before calling `whitespace-report-region' interactively, it
forces `whitespace-style' to have:

   empty
   indentation
   space-before-tab
   trailing
   space-after-tab

If REPORT-IF-BOGUS is non-nil, it reports only when there are any
whitespace problems in buffer.

For a description of whitespace problems, see
`whitespace-test-region'."
  (interactive "r")
  (setq force (or current-prefix-arg force))
  (save-excursion
    (let ((bogus-list (whitespace-test-region start end)))
      (when (if report-if-bogus bogus-list t)
        (whitespace-kill-buffer whitespace-report-buffer-name)
        ;; `whitespace-indent-tabs-mode' is local to current buffer
        ;; `whitespace-tab-width' is local to current buffer
        (let ((ws-indent-tabs-mode whitespace-indent-tabs-mode)
              (ws-tab-width whitespace-tab-width))
          (with-current-buffer (get-buffer-create
                                whitespace-report-buffer-name)
            (erase-buffer)
            (insert (if ws-indent-tabs-mode
                        (car whitespace-report-text)
                      (cdr whitespace-report-text)))
            (goto-char (point-min))
            (forward-line 3)
            (dolist (option whitespace-report-list)
              (forward-line 1)
              (whitespace-mark-x
               27 (memq (car option) whitespace-style))
              (whitespace-mark-x 7 (car bogus-list))
              (setq bogus-list (cdr bogus-list)))
            (forward-line 1)
            (whitespace-insert-value ws-indent-tabs-mode)
            (whitespace-insert-value ws-tab-width)
            (when bogus-list
              (goto-char (point-max))
              (insert " Type `M-x whitespace-cleanup'"
                      " to cleanup the buffer.\n\n"
                      " Type `M-x whitespace-cleanup-region'"
                      " to cleanup a region.\n\n"))
            (whitespace-display-window (current-buffer)))))
      (null bogus-list))))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Sat, 02 Mar 2013 03:02:02 GMT) Full text and rfc822 format available.

Message #23 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2;
	Make it possible to turn whitespace-mode only when there are no
	existing problems
Date: Fri, 01 Mar 2013 22:01:07 -0500
>> You can … refactor the
>> whitespace-report-region so as to provide whitespace-test-region.
> Here's an attempt at that:

Can you please (re)send it as a patch?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Sat, 02 Mar 2013 03:03:02 GMT) Full text and rfc822 format available.

Message #26 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2;
	Make it possible to turn whitespace-mode only when there are no
	existing problems
Date: Fri, 01 Mar 2013 22:02:28 -0500
>> (add-function :after-while (default-value 'whitespace-enable-predicate)
>>               #'whitespace-check-cleanliness)
> Emacs 24 doesn't seem to have add-function;

We're talking about changing whitespace.el, so I take it for granted
that this can be a "trunk-only" solution.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Sat, 02 Mar 2013 07:47:02 GMT) Full text and rfc822 format available.

Message #29 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
	when there are no existing problems
Date: Sat, 2 Mar 2013 07:46:31 +0000
On 2 March 2013 03:02, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>>> (add-function :after-while (default-value 'whitespace-enable-predicate)
>>>               #'whitespace-check-cleanliness)
>> Emacs 24 doesn't seem to have add-function;
>
> We're talking about changing whitespace.el, so I take it for granted
> that this can be a "trunk-only" solution.

This was a bit of code you suggested putting in my .emacs, not
patching whitespace.el. If possible, I'd like something I can use
today with Emacs 24.

-- 
http://rrt.sc3d.org




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Sat, 02 Mar 2013 07:50:01 GMT) Full text and rfc822 format available.

Message #32 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
	when there are no existing problems
Date: Sat, 2 Mar 2013 07:49:35 +0000
On 2 March 2013 03:01, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>>> You can … refactor the
>>> whitespace-report-region so as to provide whitespace-test-region.
>> Here's an attempt at that:
>
> Can you please (re)send it as a patch?

Sure:

=== modified file 'lisp/whitespace.el'
--- lisp/whitespace.el    2013-01-11 23:08:55 +0000
+++ lisp/whitespace.el    2013-03-02 07:47:43 +0000
@@ -1821,6 +1821,64 @@


 ;;;###autoload
+(defun whitespace-test-region (start end)
+  "Find whether there are whitespace problems in a region.
+
+Return a list of whitespace problems (hence, nil if there is no
+whitespace problem).
+
+A whitespace problem is one of the following:
+
+* If `indent-tabs-mode' is non-nil:
+   empty        1. empty lines at beginning of buffer.
+   empty        2. empty lines at end of buffer.
+   trailing        3. SPACEs or TABs at end of line.
+   indentation        4. 8 or more SPACEs at beginning of line.
+   space-before-tab    5. SPACEs before TAB.
+   space-after-tab    6. 8 or more SPACEs after TAB.
+
+* If `indent-tabs-mode' is nil:
+   empty        1. empty lines at beginning of buffer.
+   empty        2. empty lines at end of buffer.
+   trailing        3. SPACEs or TABs at end of line.
+   indentation        4. TABS at beginning of line.
+   space-before-tab    5. SPACEs before TAB.
+   space-after-tab    6. 8 or more SPACEs after TAB.
+
+See `whitespace-style' for documentation.
+See also `whitespace-cleanup' and `whitespace-cleanup-region' for
+cleaning up these problems."
+  (save-excursion
+    (save-match-data                ;FIXME: Why?
+      (let* ((has-bogus nil)
+             (rstart    (min start end))
+             (rend      (max start end))
+             (bogus-list
+              (mapcar
+               #'(lambda (option)
+                   (goto-char rstart)
+                   (let ((regexp
+                          (cond
+                           ((eq (car option) 'indentation)
+                            (whitespace-indentation-regexp))
+                           ((eq (car option) 'indentation::tab)
+                            (whitespace-indentation-regexp 'tab))
+                           ((eq (car option) 'indentation::space)
+                            (whitespace-indentation-regexp 'space))
+                           ((eq (car option) 'space-after-tab)
+                            (whitespace-space-after-tab-regexp))
+                           ((eq (car option) 'space-after-tab::tab)
+                            (whitespace-space-after-tab-regexp 'tab))
+                           ((eq (car option) 'space-after-tab::space)
+                            (whitespace-space-after-tab-regexp 'space))
+                           (t
+                            (cdr option)))))
+                     (and (re-search-forward regexp rend t)
+                          t)))
+               whitespace-report-list)))
+        bogus-list))))
+
+;;;###autoload
 (defun whitespace-report-region (start end &optional force report-if-bogus)
   "Report some whitespace problems in a region.

@@ -1840,90 +1898,43 @@
 If REPORT-IF-BOGUS is non-nil, it reports only when there are any
 whitespace problems in buffer.

-Report if some of the following whitespace problems exist:
-
-* If `indent-tabs-mode' is non-nil:
-   empty        1. empty lines at beginning of buffer.
-   empty        2. empty lines at end of buffer.
-   trailing        3. SPACEs or TABs at end of line.
-   indentation        4. 8 or more SPACEs at beginning of line.
-   space-before-tab    5. SPACEs before TAB.
-   space-after-tab    6. 8 or more SPACEs after TAB.
-
-* If `indent-tabs-mode' is nil:
-   empty        1. empty lines at beginning of buffer.
-   empty        2. empty lines at end of buffer.
-   trailing        3. SPACEs or TABs at end of line.
-   indentation        4. TABS at beginning of line.
-   space-before-tab    5. SPACEs before TAB.
-   space-after-tab    6. 8 or more SPACEs after TAB.
-
-See `whitespace-style' for documentation.
-See also `whitespace-cleanup' and `whitespace-cleanup-region' for
-cleaning up these problems."
+For a description of whitespace problems, see
+`whitespace-test-region'."
   (interactive "r")
   (setq force (or current-prefix-arg force))
   (save-excursion
-    (save-match-data                ;FIXME: Why?
-      (let* ((has-bogus nil)
-         (rstart    (min start end))
-         (rend      (max start end))
-         (bogus-list
-          (mapcar
-           #'(lambda (option)
-           (when force
-             (add-to-list 'whitespace-style (car option)))
-           (goto-char rstart)
-           (let ((regexp
-              (cond
-               ((eq (car option) 'indentation)
-                (whitespace-indentation-regexp))
-               ((eq (car option) 'indentation::tab)
-                (whitespace-indentation-regexp 'tab))
-               ((eq (car option) 'indentation::space)
-                (whitespace-indentation-regexp 'space))
-               ((eq (car option) 'space-after-tab)
-                (whitespace-space-after-tab-regexp))
-               ((eq (car option) 'space-after-tab::tab)
-                (whitespace-space-after-tab-regexp 'tab))
-               ((eq (car option) 'space-after-tab::space)
-                (whitespace-space-after-tab-regexp 'space))
-               (t
-                (cdr option)))))
-             (and (re-search-forward regexp rend t)
-              (setq has-bogus t))))
-           whitespace-report-list)))
-    (when (if report-if-bogus has-bogus t)
-      (whitespace-kill-buffer whitespace-report-buffer-name)
-      ;; `whitespace-indent-tabs-mode' is local to current buffer
-      ;; `whitespace-tab-width' is local to current buffer
-      (let ((ws-indent-tabs-mode whitespace-indent-tabs-mode)
-        (ws-tab-width whitespace-tab-width))
-        (with-current-buffer (get-buffer-create
-                  whitespace-report-buffer-name)
-          (erase-buffer)
-          (insert (if ws-indent-tabs-mode
-              (car whitespace-report-text)
-            (cdr whitespace-report-text)))
-          (goto-char (point-min))
-          (forward-line 3)
-          (dolist (option whitespace-report-list)
-        (forward-line 1)
-        (whitespace-mark-x
-         27 (memq (car option) whitespace-style))
-        (whitespace-mark-x 7 (car bogus-list))
-        (setq bogus-list (cdr bogus-list)))
-          (forward-line 1)
-          (whitespace-insert-value ws-indent-tabs-mode)
-          (whitespace-insert-value ws-tab-width)
-          (when has-bogus
-        (goto-char (point-max))
-        (insert " Type `M-x whitespace-cleanup'"
-            " to cleanup the buffer.\n\n"
-            " Type `M-x whitespace-cleanup-region'"
-            " to cleanup a region.\n\n"))
-          (whitespace-display-window (current-buffer)))))
-    has-bogus))))
+    (let ((bogus-list (whitespace-test-region start end)))
+      (when (if report-if-bogus bogus-list t)
+        (whitespace-kill-buffer whitespace-report-buffer-name)
+        ;; `whitespace-indent-tabs-mode' is local to current buffer
+        ;; `whitespace-tab-width' is local to current buffer
+        (let ((ws-indent-tabs-mode whitespace-indent-tabs-mode)
+              (ws-tab-width whitespace-tab-width))
+          (with-current-buffer (get-buffer-create
+                                whitespace-report-buffer-name)
+            (erase-buffer)
+            (insert (if ws-indent-tabs-mode
+                        (car whitespace-report-text)
+                      (cdr whitespace-report-text)))
+            (goto-char (point-min))
+            (forward-line 3)
+            (dolist (option whitespace-report-list)
+              (forward-line 1)
+              (whitespace-mark-x
+               27 (memq (car option) whitespace-style))
+              (whitespace-mark-x 7 (car bogus-list))
+              (setq bogus-list (cdr bogus-list)))
+            (forward-line 1)
+            (whitespace-insert-value ws-indent-tabs-mode)
+            (whitespace-insert-value ws-tab-width)
+            (when bogus-list
+              (goto-char (point-max))
+              (insert " Type `M-x whitespace-cleanup'"
+                      " to cleanup the buffer.\n\n"
+                      " Type `M-x whitespace-cleanup-region'"
+                      " to cleanup a region.\n\n"))
+            (whitespace-display-window (current-buffer)))))
+      (null bogus-list))))


 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


--
http://rrt.sc3d.org




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Sun, 03 Mar 2013 23:37:02 GMT) Full text and rfc822 format available.

Message #35 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2;
	Make it possible to turn whitespace-mode only when there are no
	existing problems
Date: Sun, 03 Mar 2013 18:36:03 -0500
> This was a bit of code you suggested putting in my .emacs, not
> patching whitespace.el.  If possible, I'd like something I can use
> today with Emacs 24.

You already have "something I can use today with Emacs 24" and by
definition whatever we change in trunk won't really help you if you need
it to work in older Emacsen.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Wed, 10 Apr 2013 00:54:01 GMT) Full text and rfc822 format available.

Message #38 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
	when there are no existing problems
Date: Wed, 10 Apr 2013 01:50:10 +0100
[Message part 1 (text/plain, inline)]
On 2 March 2013 07:49, Reuben Thomas <rrt <at> sc3d.org> wrote:

> On 2 March 2013 03:01, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
> >>> You can … refactor the
> >>> whitespace-report-region so as to provide whitespace-test-region.
> >> Here's an attempt at that:
> >
> > Can you please (re)send it as a patch?
>
> Sure:
>
> === modified file 'lisp/whitespace.el'
>

[patch snipped]

Ping?

-- 
http://rrt.sc3d.org
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Thu, 17 Oct 2013 23:11:03 GMT) Full text and rfc822 format available.

Message #41 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
 when there are no existing problems
Date: Fri, 18 Oct 2013 00:09:57 +0100
[Message part 1 (text/plain, inline)]
On 10 April 2013 01:50, Reuben Thomas <rrt <at> sc3d.org> wrote:

> On 2 March 2013 07:49, Reuben Thomas <rrt <at> sc3d.org> wrote:
>
>> On 2 March 2013 03:01, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>> >>> You can … refactor the
>> >>> whitespace-report-region so as to provide whitespace-test-region.
>> >> Here's an attempt at that:
>> >
>> > Can you please (re)send it as a patch?
>>
>> Sure:
>>
>> === modified file 'lisp/whitespace.el'
>>
>
> [patch snipped]
>
> Ping?
>

Ping again? My patch still applies cleanly to trunk.

-- 
http://rrt.sc3d.org
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Sun, 26 Jan 2014 23:13:01 GMT) Full text and rfc822 format available.

Message #44 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
 when there are no existing problems
Date: Sun, 26 Jan 2014 23:12:10 +0000
[Message part 1 (text/plain, inline)]
On 18 October 2013 00:09, Reuben Thomas <rrt <at> sc3d.org> wrote:

> On 10 April 2013 01:50, Reuben Thomas <rrt <at> sc3d.org> wrote:
>
>> On 2 March 2013 07:49, Reuben Thomas <rrt <at> sc3d.org> wrote:
>>
>>> On 2 March 2013 03:01, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>>> >>> You can … refactor the
>>> >>> whitespace-report-region so as to provide whitespace-test-region.
>>> >> Here's an attempt at that:
>>> >
>>> > Can you please (re)send it as a patch?
>>>
>>> Sure:
>>>
>>> === modified file 'lisp/whitespace.el'
>>>
>>
>> [patch snipped]
>>
>> Ping?
>>
>
> Ping again? My patch still applies cleanly to trunk.
>

Ping again! My patch still applies cleanly to trunk. Just to repeat why
this patch is worthwhile, it splits out a function whitespace-test-region
which can usefully be used to advise whitespace-enable-predicate. (For use
with 24.3, I simply redefine whitespace-enable-predicate instead.)

-- 
http://rrt.sc3d.org
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Sun, 26 Jan 2014 23:30:02 GMT) Full text and rfc822 format available.

Message #47 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#13837: 24.2;
 Make it possible to turn whitespace-mode only when there are no
 existing problems
Date: Mon, 27 Jan 2014 01:29:21 +0200
Reuben Thomas <rrt <at> sc3d.org> writes:

> Ping again! My patch still applies cleanly to trunk.

That's great, but we're in feature freeze now, so the patch will
probably have to wait until the trunk is unfrozen for changes (and thus
will only be incorporated in whatever version comes after Emacs 24.4).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Sun, 26 Jan 2014 23:32:01 GMT) Full text and rfc822 format available.

Message #50 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 13837 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
 when there are no existing problems
Date: Sun, 26 Jan 2014 23:31:52 +0000
[Message part 1 (text/plain, inline)]
On 26 January 2014 23:29, Dmitry Gutov <dgutov <at> yandex.ru> wrote:

> Reuben Thomas <rrt <at> sc3d.org> writes:
>
> > Ping again! My patch still applies cleanly to trunk.
>
> That's great, but we're in feature freeze now, so the patch will
> probably have to wait until the trunk is unfrozen for changes (and thus
> will only be incorporated in whatever version comes after Emacs 24.4).
>

That's a pity: this patch has been available in its current form for nearly
a year, and I last pinged a couple of weeks before feature freeze. But I
await 24.4 with impatience too!

-- 
http://rrt.sc3d.org
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Mon, 27 Jan 2014 00:28:02 GMT) Full text and rfc822 format available.

Message #53 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
 when there are no existing problems
Date: Mon, 27 Jan 2014 02:27:51 +0200
On 27.01.2014 01:31, Reuben Thomas wrote:
> That's a pity: this patch has been available in its current form for
> nearly a year, and I last pinged a couple of weeks before feature
> freeze. But I await 24.4 with impatience too!

Alas, this bug wasn't tagged as having a patch, so it eluded the 
pre-feature freeze call-to-arms.

But it's up to Stefan. Maybe this change can pass as "already discussed".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Mon, 27 Jan 2014 00:42:01 GMT) Full text and rfc822 format available.

Message #56 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 13837 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
 when there are no existing problems
Date: Mon, 27 Jan 2014 00:41:19 +0000
[Message part 1 (text/plain, inline)]
On 27 January 2014 00:27, Dmitry Gutov <dgutov <at> yandex.ru> wrote:

> On 27.01.2014 01:31, Reuben Thomas wrote:
>
>> That's a pity: this patch has been available in its current form for
>> nearly a year, and I last pinged a couple of weeks before feature
>> freeze. But I await 24.4 with impatience too!
>>
>
> Alas, this bug wasn't tagged as having a patch, so it eluded the
> pre-feature freeze call-to-arms.
>

Thanks for that information, I can try to remember to tag bugs in future
when I provide a patch.

-- 
http://rrt.sc3d.org
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Mon, 27 Jan 2014 01:53:02 GMT) Full text and rfc822 format available.

Message #59 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#13837: 24.2;
 Make it possible to turn whitespace-mode only when there are no
 existing problems
Date: Sun, 26 Jan 2014 20:52:50 -0500
> Thanks for that information, I can try to remember to tag bugs in future
> when I provide a patch.

I could be convinced to install it if it's "obviously safe".
The patch as sent is a large chunk of "new" code plus a large chunk of
"removed" code, so it's not very appealing.  Diffing while ignoring
whitespace indicates it's more of a "refactoring", and by introducing an
"artificial" new function while helps keep the text lines in the
original order (and hence helps reduce the size of the diff), I get the
patch below.

But it's not obviously safe to me.  Two non-obvious parts are:
- the removal of "(add-to-list 'whitespace-style (car option))".
- the change from has-bogus to bogus-list, where bogus-list will
  (initially) only be nil if whitespace-report-list is nil.
Another problem is that the docstring of whitespace-test-region does not
accurately describe its return value.
So it's probably best to keep it for after 24.4, but let's try to
deal with it as soon as the trunk reopens (real soon now).


        Stefan


=== modified file 'lisp/whitespace.el'
--- lisp/whitespace.el	2014-01-06 06:25:30 +0000
+++ lisp/whitespace.el	2014-01-27 01:35:49 +0000
@@ -1779,7 +1779,20 @@
 If REPORT-IF-BOGUS is non-nil, it reports only when there are any
 whitespace problems in buffer.
 
-Report if some of the following whitespace problems exist:
+For a description of whitespace problems, see
+`whitespace-test-region'."
+  (interactive "r")
+  (setq force (or current-prefix-arg force))
+  (whitespace--report-region start end force report-if-bogus))
+
+;;;###autoload
+(defun whitespace-test-region (start end)
+  "Find whether there are whitespace problems in a region.
+
+Return a list of whitespace problems (hence, nil if there is no
+whitespace problem).
+
+A whitespace problem is one of the following:
 
 * If `indent-tabs-mode' is non-nil:
    empty		1. empty lines at beginning of buffer.
@@ -1800,18 +1813,13 @@
 See `whitespace-style' for documentation.
 See also `whitespace-cleanup' and `whitespace-cleanup-region' for
 cleaning up these problems."
-  (interactive "r")
-  (setq force (or current-prefix-arg force))
   (save-excursion
     (save-match-data                ;FIXME: Why?
-      (let* ((has-bogus nil)
-	     (rstart    (min start end))
+      (let* ((rstart    (min start end))
 	     (rend      (max start end))
 	     (bogus-list
 	      (mapcar
 	       #'(lambda (option)
-		   (when force
-		     (add-to-list 'whitespace-style (car option)))
 		   (goto-char rstart)
 		   (let ((regexp
 			  (cond
@@ -1830,9 +1838,14 @@
 			   (t
 			    (cdr option)))))
 		     (and (re-search-forward regexp rend t)
-			  (setq has-bogus t))))
+                          t)))
 	       whitespace-report-list)))
-	(when (if report-if-bogus has-bogus t)
+        bogus-list))))
+
+(defun whitespace--report-region (start end &optional force report-if-bogus)
+  (save-excursion
+    (let ((bogus-list (whitespace-test-region start end)))
+      (when (if report-if-bogus bogus-list t)
 	  (whitespace-kill-buffer whitespace-report-buffer-name)
 	  ;; `whitespace-indent-tabs-mode' is local to current buffer
 	  ;; `whitespace-tab-width' is local to current buffer
@@ -1855,14 +1868,14 @@
 	      (forward-line 1)
 	      (whitespace-insert-value ws-indent-tabs-mode)
 	      (whitespace-insert-value ws-tab-width)
-	      (when has-bogus
+            (when bogus-list
 		(goto-char (point-max))
 		(insert " Type `M-x whitespace-cleanup'"
 			" to cleanup the buffer.\n\n"
 			" Type `M-x whitespace-cleanup-region'"
 			" to cleanup a region.\n\n"))
 	      (whitespace-display-window (current-buffer)))))
-	has-bogus))))
+      (null bogus-list))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Mon, 27 Jan 2014 13:26:01 GMT) Full text and rfc822 format available.

Message #62 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
 when there are no existing problems
Date: Mon, 27 Jan 2014 13:25:01 +0000
[Message part 1 (text/plain, inline)]
On 27 January 2014 01:52, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

>
> I could be convinced to install it if it's "obviously safe".
> The patch as sent is a large chunk of "new" code plus a large chunk of
> "removed" code, so it's not very appealing.  Diffing while ignoring
> whitespace indicates it's more of a "refactoring", and by introducing an
> "artificial" new function while helps keep the text lines in the
> original order (and hence helps reduce the size of the diff), I get the
> patch below.
>

Thanks very much for trying.


> But it's not obviously safe to me.  Two non-obvious parts are:
> - the removal of "(add-to-list 'whitespace-style (car option))".
>

The removal looks wrong to me too: without that code, the force argument
has no effect. On the other hand, the way it's implemented also seems
wrong, as it permanently changes whitespace-style.


> - the change from has-bogus to bogus-list, where bogus-list will
>   (initially) only be nil if whitespace-report-list is nil.
>

As far as I can see, has-bogus was set whenever an element was added to
bogus-list. Hence, bogus-list is nil when has-bogus was nil. bogus-list is
a list of whichever elements of whitespace-report-list problems are found,
so if no problem is found, it will be nil.


> Another problem is that the docstring of whitespace-test-region does not
> accurately describe its return value.
>

So the return value is currently a list of flags corresponding to elements
of whitespace-report-list.

Two more things:

1. I would like to refactor the description of whitespace problems in
whitespace-report-region to move those which are the same regardless of the
value of indent-tabs-mode into a separate list.

2. Since we're no longer going for getting this into 24.4, can we fold your
"artificial" whitespace--report-report-region back into
whitespace-report-region, which both simplifies the end result slightly,
and avoids the question of whether the new function should be moved down
into "internal functions"?
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Mon, 27 Jan 2014 15:01:01 GMT) Full text and rfc822 format available.

Message #65 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#13837: 24.2;
 Make it possible to turn whitespace-mode only when there are no
 existing problems
Date: Mon, 27 Jan 2014 10:00:30 -0500
>> But it's not obviously safe to me.  Two non-obvious parts are:
>> - the removal of "(add-to-list 'whitespace-style (car option))".
> The removal looks wrong to me too: without that code, the force argument
> has no effect.  On the other hand, the way it's implemented also seems
> wrong, as it permanently changes whitespace-style.

Agreed on both aspects.

>> - the change from has-bogus to bogus-list, where bogus-list will
>> (initially) only be nil if whitespace-report-list is nil.
> As far as I can see, has-bogus was set whenever an element was added to
> bogus-list.

The way I read the code bogus-list is a list of booleans (either nil or
t), returned by `mapcar', so it has as many elements as
whitespace-report-list.  IOW an element was/is added to bogus-list
regardless if a test succeeds/fails.

> 1. I would like to refactor the description of whitespace problems in
> whitespace-report-region to move those which are the same regardless of the
> value of indent-tabs-mode into a separate list.

Fine.

> 2. Since we're no longer going for getting this into 24.4, can we fold your
> "artificial" whitespace--report-report-region back into
> whitespace-report-region, which both simplifies the end result slightly,
> and avoids the question of whether the new function should be moved down
> into "internal functions"?

Of course,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Mon, 27 Jan 2014 21:20:01 GMT) Full text and rfc822 format available.

Message #68 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#13837: 24.2;
 Make it possible to turn whitespace-mode only when there are no
 existing problems
Date: Mon, 27 Jan 2014 21:19:27 -0000
I’ve thought about the approach taken by my original patch and
concluded that it’s wrong: better not to split
whitespace-report-region, but instead allow it not to report. If the
report parameter (renamed from report-if-bogus) is 'never, then it
does not report any problem.

I’ve updated the docstring describing whitespace problems to common up
the indent-tabs-mode true/false lists as promised.

The unconditional updating of whitespace-style remains.

Patch follows.

=== modified file 'lisp/whitespace.el'
--- lisp/whitespace.el	2014-01-27 12:30:17 +0000
+++ lisp/whitespace.el	2014-01-27 21:03:00 +0000
@@ -1714,7 +1714,7 @@
 
 
 ;;;###autoload
-(defun whitespace-report (&optional force report-if-bogus)
+(defun whitespace-report (&optional force report)
   "Report some whitespace problems in buffer.
 
 Return nil if there is no whitespace problem; otherwise, return
@@ -1730,8 +1730,8 @@
    space-before-tab
    space-after-tab
 
-If REPORT-IF-BOGUS is non-nil, it reports only when there are any
-whitespace problems in buffer.
+If REPORT is t, it reports only when there are any whitespace
+problems in buffer; if it is 'never, it does not report problems.
 
 Report if some of the following whitespace problems exist:
 
@@ -1756,11 +1756,11 @@
 cleaning up these problems."
   (interactive (list current-prefix-arg))
   (whitespace-report-region (point-min) (point-max)
-			    force report-if-bogus))
+			    force report))
 
 
 ;;;###autoload
-(defun whitespace-report-region (start end &optional force report-if-bogus)
+(defun whitespace-report-region (start end &optional force report)
   "Report some whitespace problems in a region.
 
 Return nil if there is no whitespace problem; otherwise, return
@@ -1776,26 +1776,22 @@
    trailing
    space-after-tab
 
-If REPORT-IF-BOGUS is non-nil, it reports only when there are any
-whitespace problems in buffer.
+If REPORT is t, it reports only when there are any whitespace
+problems in buffer; if it is 'never, it does not report problems.
 
 Report if some of the following whitespace problems exist:
 
+   empty		1. empty lines at beginning of buffer.
+   empty		2. empty lines at end of buffer.
+   trailing		3. SPACEs or TABs at end of line.
+   space-before-tab	4. SPACEs before TAB.
+   space-after-tab	5. 8 or more SPACEs after TAB.
+
 * If `indent-tabs-mode' is non-nil:
-   empty		1. empty lines at beginning of buffer.
-   empty		2. empty lines at end of buffer.
-   trailing		3. SPACEs or TABs at end of line.
-   indentation		4. 8 or more SPACEs at beginning of line.
-   space-before-tab	5. SPACEs before TAB.
-   space-after-tab	6. 8 or more SPACEs after TAB.
+   indentation		6. 8 or more SPACEs at beginning of line.
 
 * If `indent-tabs-mode' is nil:
-   empty		1. empty lines at beginning of buffer.
-   empty		2. empty lines at end of buffer.
-   trailing		3. SPACEs or TABs at end of line.
-   indentation		4. TABS at beginning of line.
-   space-before-tab	5. SPACEs before TAB.
-   space-after-tab	6. 8 or more SPACEs after TAB.
+   indentation		6. TABS at beginning of line.
 
 See `whitespace-style' for documentation.
 See also `whitespace-cleanup' and `whitespace-cleanup-region' for
@@ -1832,7 +1828,7 @@
 		     (and (re-search-forward regexp rend t)
 			  (setq has-bogus t))))
 	       whitespace-report-list)))
-	(when (if report-if-bogus has-bogus t)
+	(when (if (equal report t) has-bogus (null report))
 	  (whitespace-kill-buffer whitespace-report-buffer-name)
 	  ;; `whitespace-indent-tabs-mode' is local to current buffer
 	  ;; `whitespace-tab-width' is local to current buffer

-- 
http://rrt.sc3d.org/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Tue, 28 Jan 2014 00:33:01 GMT) Full text and rfc822 format available.

Message #71 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#13837: 24.2;
 Make it possible to turn whitespace-mode only when there are no
 existing problems
Date: Mon, 27 Jan 2014 19:32:41 -0500
> -(defun whitespace-report (&optional force report-if-bogus)
> +(defun whitespace-report (&optional force report)

I'd leave the name unchanged.  Will make for a cleaner diff and the
name "report" is not convincingly better.

> +If REPORT is t, it reports only when there are any whitespace
> +problems in buffer; if it is 'never, it does not report problems.
                                ^^^^^^
should be                       `never'

> +problems in buffer; if it is 'never, it does not report problems.
                                ^^^^^^
should be                       `never'
 
>  * If `indent-tabs-mode' is non-nil:
> +   indentation		6. 8 or more SPACEs at beginning of line.
>  * If `indent-tabs-mode' is nil:
> +   indentation		6. TABS at beginning of line.

Why not

      indentation		6. if `indent-tabs-mode':
                                   8 or more SPACEs at beginning of line
                                   else: TABS at beginning of line.

> -	(when (if report-if-bogus has-bogus t)
> +	(when (if (equal report t) has-bogus (null report))

For better backward compatibility, this should check for `never' and
treat any other non-nil value as t.   IOW

	(when (pcase report-if-bogus (`nil t) (`never nil) (_ has-bogus))


-- Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Tue, 28 Jan 2014 00:49:02 GMT) Full text and rfc822 format available.

Message #74 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
 when there are no existing problems
Date: Tue, 28 Jan 2014 00:48:21 +0000
[Message part 1 (text/plain, inline)]
On 28 January 2014 00:32, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

> > -(defun whitespace-report (&optional force report-if-bogus)
> > +(defun whitespace-report (&optional force report)
>
> I'd leave the name unchanged.  Will make for a cleaner diff and the
> name "report" is not convincingly better.
>

Sure, OK.


>  > +If REPORT is t, it reports only when there are any whitespace
> > +problems in buffer; if it is 'never, it does not report problems.
>                                 ^^^^^^
> should be                       `never'
>
> > +problems in buffer; if it is 'never, it does not report problems.
>                                 ^^^^^^
> should be                       `never'
>
> >  * If `indent-tabs-mode' is non-nil:
> > +   indentation               6. 8 or more SPACEs at beginning of line.
> >  * If `indent-tabs-mode' is nil:
> > +   indentation               6. TABS at beginning of line.
>
> Why not
>
>       indentation               6. if `indent-tabs-mode':
>                                    8 or more SPACEs at beginning of line
>                                    else: TABS at beginning of line.
>

OK.


> > -     (when (if report-if-bogus has-bogus t)
> > +     (when (if (equal report t) has-bogus (null report))
>
> For better backward compatibility, this should check for `never' and
> treat any other non-nil value as t.   IOW
>
>         (when (pcase report-if-bogus (`nil t) (`never nil) (_ has-bogus))
>

Fine, revised patch to follow.

-- 
http://rrt.sc3d.org
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Thu, 29 May 2014 17:27:02 GMT) Full text and rfc822 format available.

Message #77 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2;
 Make it possible to turn whitespace-mode only when there are no
 existing problems
Date: Thu, 29 May 2014 13:26:14 -0400
In January you wrote:
> Fine, revised patch to follow.

Hmm... Did I miss it, or are you waiting for something?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Thu, 29 May 2014 19:02:01 GMT) Full text and rfc822 format available.

Message #80 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
 when there are no existing problems
Date: Thu, 29 May 2014 20:01:31 +0100
[Message part 1 (text/plain, inline)]
On 29 May 2014 18:26, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

> In January you wrote:
> > Fine, revised patch to follow.
>
> Hmm... Did I miss it, or are you waiting for something?


 I sent the patch and you replied "Looks good, thank you,"

Unfortunately, I sent the patch only to you, as I managed to somehow get
what should have been the contents of the Cc: header into the Subject
instead. I will now resend it, sorry.

-- 
http://rrt.sc3d.org
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Thu, 29 May 2014 19:03:01 GMT) Full text and rfc822 format available.

Message #83 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org, Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
 when there are no existing problems
Date: Thu, 29 May 2014 20:02:49 +0100
[Message part 1 (text/plain, inline)]
Revised patch as promised. [Resent owing to addressing error the first time
around.]

=== modified file 'lisp/whitespace.el'
--- lisp/whitespace.el  2014-01-27 12:30:17 +0000
+++ lisp/whitespace.el  2014-01-28 00:41:32 +0000
@@ -1730,8 +1730,9 @@
    space-before-tab
    space-after-tab

-If REPORT-IF-BOGUS is non-nil, it reports only when there are any
-whitespace problems in buffer.
+If REPORT-IF-BOGUS is t, it reports only when there are any
+whitespace problems in buffer; if it is `never', it does not
+report problems.

 Report if some of the following whitespace problems exist:

@@ -1776,26 +1777,20 @@
    trailing
    space-after-tab

-If REPORT-IF-BOGUS is non-nil, it reports only when there are any
-whitespace problems in buffer.
+If REPORT-IF-BOGUS is t, it reports only when there are any
+whitespace problems in buffer; if it is `never', it does not
+report problems.

 Report if some of the following whitespace problems exist:

-* If `indent-tabs-mode' is non-nil:
-   empty               1. empty lines at beginning of buffer.
-   empty               2. empty lines at end of buffer.
-   trailing            3. SPACEs or TABs at end of line.
-   indentation         4. 8 or more SPACEs at beginning of line.
-   space-before-tab    5. SPACEs before TAB.
-   space-after-tab     6. 8 or more SPACEs after TAB.
-
-* If `indent-tabs-mode' is nil:
-   empty               1. empty lines at beginning of buffer.
-   empty               2. empty lines at end of buffer.
-   trailing            3. SPACEs or TABs at end of line.
-   indentation         4. TABS at beginning of line.
-   space-before-tab    5. SPACEs before TAB.
-   space-after-tab     6. 8 or more SPACEs after TAB.
+   empty               1. empty lines at beginning of buffer.
+   empty               2. empty lines at end of buffer.
+   trailing            3. SPACEs or TABs at end of line.
+   space-before-tab    4. SPACEs before TAB.
+   space-after-tab     5. 8 or more SPACEs after TAB.
+   indentation         6. If `indent-tabs-mode':
+                           8 or more SPACEs at beginning of line
+                           else: TABS at beginning of line.

 See `whitespace-style' for documentation.
 See also `whitespace-cleanup' and `whitespace-cleanup-region' for
@@ -1832,7 +1827,7 @@
                     (and (re-search-forward regexp rend t)
                          (setq has-bogus t))))
               whitespace-report-list)))
-       (when (if report-if-bogus has-bogus t)
+       (when (pcase report-if-bogus (`nil t) (`never nil) (_ has-bogus))
          (whitespace-kill-buffer whitespace-report-buffer-name)
          ;; `whitespace-indent-tabs-mode' is local to current buffer
          ;; `whitespace-tab-width' is local to current buffer

--
http://rrt.sc3d.org/



-- 
http://rrt.sc3d.org
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Thu, 29 May 2014 20:29:01 GMT) Full text and rfc822 format available.

Message #86 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2;
 Make it possible to turn whitespace-mode only when there are no
 existing problems
Date: Thu, 29 May 2014 16:28:10 -0400
>  I sent the patch and you replied "Looks good, thank you,"

Then, go ahead and install it,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Thu, 29 May 2014 22:54:01 GMT) Full text and rfc822 format available.

Message #89 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Reuben Thomas <rrt <at> sc3d.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13837 <at> debbugs.gnu.org
Subject: Re: bug#13837: 24.2; Make it possible to turn whitespace-mode only
 when there are no existing problems
Date: Thu, 29 May 2014 23:53:09 +0100
[Message part 1 (text/plain, inline)]
On 29 May 2014 21:28, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

> >  I sent the patch and you replied "Looks good, thank you,"
>
> Then, go ahead and install it,
>

Done. Apologies for the hiccups in the commit log. This bug can now be
closed.

-- 
http://rrt.sc3d.org
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13837; Package emacs. (Fri, 30 May 2014 02:02:01 GMT) Full text and rfc822 format available.

Message #92 received at 13837 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Reuben Thomas <rrt <at> sc3d.org>
Cc: 13837 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#13837: 24.2;
 Make it possible to turn whitespace-mode only when there are no
 existing problems
Date: Thu, 29 May 2014 22:01:56 -0400
Reuben Thomas wrote:

> This bug can now be closed.

You (or anyone) can do that by mailing 13837-done <at> debbugs rather than
13837 <at> debbugs.

(I like to put "Version: 24.5" at the start of the message body, so that
the system knows what version of Emacs the fix should appear in.)




bug marked as fixed in version 24.5, send any further explanations to 13837 <at> debbugs.gnu.org and Reuben Thomas <rrt <at> sc3d.org> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 30 May 2014 15:42:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 28 Jun 2014 11:24:04 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 04 Oct 2014 16:36:04 GMT) Full text and rfc822 format available.

bug Marked as fixed in versions 25.1. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 04 Oct 2014 16:36:05 GMT) Full text and rfc822 format available.

bug No longer marked as fixed in versions 24.5. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 04 Oct 2014 16:36:05 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 02 Nov 2014 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 235 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.