GNU bug report logs - #13646
Mode-specific and file-regexp-specific settings

Previous Next

Package: emacs;

Reported by: Didier Verna <didier <at> didierverna.net>

Date: Thu, 7 Feb 2013 12:46:01 UTC

Severity: wishlist

Tags: wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.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 13646 in the body.
You can then email your comments to 13646 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#13646; Package emacs. (Thu, 07 Feb 2013 12:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Didier Verna <didier <at> didierverna.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 07 Feb 2013 12:46:02 GMT) Full text and rfc822 format available.

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

From: Didier Verna <didier <at> didierverna.net>
To: bug-gnu-emacs <at> gnu.org
Cc: viniciusjl <at> ig.com.br
Subject: Whitespace support for file/mode-specific styles and actions
Date: Thu, 07 Feb 2013 13:43:26 +0100
[Message part 1 (text/plain, inline)]
  Hello,

the following patch extends whitespace.el with the ability to specify
styles and actions on a file or mode specific basis. The rationale is
that the current unique style and action settings are not
sufficient. You may not want to see the exact same whitespace problems
in all files or major modes, and you also may not want the same actions
to be undertaken everywhere.

To make this work, some new user options are introduced (which see):
whitespace-file-style, whitespace-mode-style and their action
counterpart. When computing the style to use for a specific file,
whitespace now looks for a match on the file name, then on the major
mode, and then falls back to the global setting. Same thing for actions.

[ChangeLog (text/plain, inline)]
2013-02-07  Didier Verna  <didier <at> didierverna.net>

	Support for file/mode-specific styles and actions in whitespace.el.
	* whitespace.el: Update comments throughout the file for this new
	feature.
	(whitespace-style-custom-type): New constant.
	(whitespace-style): Use it. Update and improve docstring format.
	(whitespace-file-style)
	(whitespace-mode-style): New user options.
	(whitespace-style): New function. Handles file and mode-specific
	style settings introduced by the above new user options. Used
	throughout the file instead of the just the eponym variable.
	(whitespace-action-custom-type): New constant.
	(whitespace-action): Use it. Update and improve docstring format.
	(whitespace-file-action)
	(whitespace-mode-action): New user options.
	(whitespace-action): New function. Handles file and mode-specific
	style settings introduced by the above new user options. Used
	throughout the file instead of the just the eponym variable.
	(whitespace-cleanup)
	(whitespace-cleanup-region)
	(whitespace-report-region): Update docstring. Use the
	`whitespace-style' function instead of the eponym variable.
	(whitespace-interactive-char)
	(whitespace-toggle-list)
	(whitespace-turn-on): Handle file/mode-specific styles.
	(whitespace-action-when-on)
	(whitespace-write-file-hook)
	(whitespace-warn-when-read-only): Handle file-mode-specific
	actions by using the function `whitespace-action' instead of the
	eponym variable.
	(whitespace-space)
	(whitespace-hspace)
	(whitespace-tab)
	(whitespace-newline)
	(whitespace-trailing)
	(whitespace-line)
	(whitespace-space-before-tab)
	(whitespace-indentation)
	(whitespace-empty)
	(whitespace-space-after-tab)
	(whitespace-hspace-regexp)
	(whitespace-tab-regexp)
	(whitespace-trailing-regexp)
	(whitespace-space-before-tab-regexp)
	(whitespace-indentation-regexp)
	(whitespace-empty-at-bob-regexp)
	(whitespace-empty-at-eob-regexp)
	(whitespace-space-after-tab-regexp)
	(whitespace-line-column)
	(whitespace-display-mappings)
	(whitespace-style-value-list)
	(whitespace-active-style)
	(whitespace-toggle-options)
	(global-whitespace-toggle-options)
	(whitespace-report): Update docstrings.
[whitespace.patch (text/plain, inline)]
*** whitespace.el.orig	Thu Feb  7 12:57:24 2013
--- whitespace.el	Sat Jan 19 19:00:26 2013
***************
*** 43,49 ****
  ;;   it provides a visual mark for characters, for example, at the end
  ;;   of line (?\xB6), at SPACEs (?\xB7) and at TABs (?\xBB).
  ;;
! ;; The `whitespace-style' variable selects which way blanks are
  ;; visualized.
  ;;
  ;; Note that when whitespace is turned on, whitespace saves the
--- 43,50 ----
  ;;   it provides a visual mark for characters, for example, at the end
  ;;   of line (?\xB6), at SPACEs (?\xB7) and at TABs (?\xBB).
  ;;
! ;; The `whitespace-file-style', `whitespace-mode-style' and
! ;; `whitespace-style' variables select which way blanks are
  ;; visualized.
  ;;
  ;; Note that when whitespace is turned on, whitespace saves the
***************
*** 186,224 ****
  ;;
  ;; 1. empty lines at beginning of buffer.
  ;; 2. empty lines at end of buffer.
! ;;    If `whitespace-style' includes the value `empty', remove all
  ;;    empty lines at beginning and/or end of buffer.
  ;;
  ;; 3. 8 or more SPACEs at beginning of line.
! ;;    If `whitespace-style' includes the value `indentation':
  ;;    replace 8 or more SPACEs at beginning of line by TABs, if
  ;;    `indent-tabs-mode' is non-nil; otherwise, replace TABs by
  ;;    SPACEs.
! ;;    If `whitespace-style' includes the value `indentation::tab',
  ;;    replace 8 or more SPACEs at beginning of line by TABs.
! ;;    If `whitespace-style' includes the value `indentation::space',
  ;;    replace TABs by SPACEs.
  ;;
  ;; 4. SPACEs before TAB.
! ;;    If `whitespace-style' includes the value `space-before-tab':
  ;;    replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
  ;;    otherwise, replace TABs by SPACEs.
! ;;    If `whitespace-style' includes the value
  ;;    `space-before-tab::tab', replace SPACEs by TABs.
! ;;    If `whitespace-style' includes the value
  ;;    `space-before-tab::space', replace TABs by SPACEs.
  ;;
  ;; 5. SPACEs or TABs at end of line.
! ;;    If `whitespace-style' includes the value `trailing', remove all
  ;;    SPACEs or TABs at end of line.
  ;;
  ;; 6. 8 or more SPACEs after TAB.
! ;;    If `whitespace-style' includes the value `space-after-tab':
  ;;    replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
  ;;    otherwise, replace TABs by SPACEs.
! ;;    If `whitespace-style' includes the value `space-after-tab::tab',
  ;;    replace SPACEs by TABs.
! ;;    If `whitespace-style' includes the value
  ;;    `space-after-tab::space', replace TABs by SPACEs.
  ;;
  ;;
--- 187,225 ----
  ;;
  ;; 1. empty lines at beginning of buffer.
  ;; 2. empty lines at end of buffer.
! ;;    If whitespace style includes the value `empty', remove all
  ;;    empty lines at beginning and/or end of buffer.
  ;;
  ;; 3. 8 or more SPACEs at beginning of line.
! ;;    If whitespace style includes the value `indentation':
  ;;    replace 8 or more SPACEs at beginning of line by TABs, if
  ;;    `indent-tabs-mode' is non-nil; otherwise, replace TABs by
  ;;    SPACEs.
! ;;    If whitespace style includes the value `indentation::tab',
  ;;    replace 8 or more SPACEs at beginning of line by TABs.
! ;;    If whitespace style includes the value `indentation::space',
  ;;    replace TABs by SPACEs.
  ;;
  ;; 4. SPACEs before TAB.
! ;;    If whitespace style includes the value `space-before-tab':
  ;;    replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
  ;;    otherwise, replace TABs by SPACEs.
! ;;    If whitespace style includes the value
  ;;    `space-before-tab::tab', replace SPACEs by TABs.
! ;;    If whitespace style includes the value
  ;;    `space-before-tab::space', replace TABs by SPACEs.
  ;;
  ;; 5. SPACEs or TABs at end of line.
! ;;    If whitespace style includes the value `trailing', remove all
  ;;    SPACEs or TABs at end of line.
  ;;
  ;; 6. 8 or more SPACEs after TAB.
! ;;    If whitespace style includes the value `space-after-tab':
  ;;    replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
  ;;    otherwise, replace TABs by SPACEs.
! ;;    If whitespace style includes the value `space-after-tab::tab',
  ;;    replace SPACEs by TABs.
! ;;    If whitespace style includes the value
  ;;    `space-after-tab::space', replace TABs by SPACEs.
  ;;
  ;;
***************
*** 243,248 ****
--- 244,251 ----
  ;; Below it's shown a brief description of whitespace options, please,
  ;; see the options declaration in the code for a long documentation.
  ;;
+ ;; `whitespace-file-style'
+ ;; `whitespace-mode-style'
  ;; `whitespace-style'		Specify which kind of blank is
  ;;				visualized.
  ;;
***************
*** 305,310 ****
--- 308,315 ----
  ;;				`whitespace-mode' is automagically
  ;;				turned on.
  ;;
+ ;; `whitespace-file-action'
+ ;; `whitespace-mode-action'
  ;; `whitespace-action'		Specify which action is taken when a
  ;;				buffer is visited or written.
  ;;
***************
*** 383,388 ****
--- 388,448 ----
    :group 'convenience)
  
  
+ (defconst whitespace-style-custom-type
+   '(repeat :tag "Kind of Blank"
+ 	   (choice :tag "Kind of Blank Face"
+ 		   (const :tag "(Face) Face visualization" face)
+ 		   (const :tag "(Face) Trailing TABs, SPACEs and HARD SPACEs"
+ 			  trailing)
+ 		   (const :tag "(Face) SPACEs and HARD SPACEs" spaces)
+ 		   (const :tag "(Face) TABs" tabs)
+ 		   (const :tag "(Face) Lines" lines)
+ 		   (const :tag "(Face) SPACEs before TAB" space-before-tab)
+ 		   (const :tag "(Face) NEWLINEs" newline)
+ 		   (const :tag "(Face) Indentation SPACEs" indentation)
+ 		   (const :tag "(Face) Empty Lines At BOB And/Or EOB" empty)
+ 		   (const :tag "(Face) SPACEs after TAB" space-after-tab)
+ 		   (const :tag "(Mark) SPACEs and HARD SPACEs" space-mark)
+ 		   (const :tag "(Mark) TABs" tab-mark)
+ 		   (const :tag "(Mark) NEWLINEs" newline-mark)))
+   ;; Custom type specification for Whitespace styles. Used in
+   ;; WHITESPACE-FILE-STYLE, WHITESPACE-MODE-STYLE and
+   ;; WHITESPACE-STYLE.
+   )
+ 
+ (defcustom whitespace-file-style nil
+   "Specify which kind of blank is visualized for specific files.
+ 
+ This is a list of elements of the form (REGEXP STYLE...) where
+ REGEXP is matched against file names.  For a list of possible
+ STYLEs, see `whitespace-style'.
+ 
+ Whitespace determines which style to use on a specific buffer by
+ trying a match from this variable, then from
+ `whitespace-mode-style' and then by falling back to
+ `whitespace-style'."
+   :type `(repeat (cons :value ("")
+ 		       (regexp :tag "File Name Matching")
+ 		       ,whitespace-style-custom-type))
+   :version "24.3"
+   :group 'whitespace)
+ 
+ (defcustom whitespace-mode-style nil
+   "Specify which kind of blank is visualized for specific major modes.
+ 
+ This is a list of elements of the form (MODE STYLE...) where MODE
+ is a major mode name.  For a list of possible STYLEs, see
+ `whitespace-style'.
+ 
+ Whitespace determines which style to use on a specific buffer by
+ trying a match from `whitespace-file-style', then from this
+ variable and then by falling back to `whitespace-style'."
+   :type `(repeat (cons :value (fundamental-mode)
+ 		       (symbol :tag "Major Mode")
+ 		       ,whitespace-style-custom-type))
+   :version "24.3"
+   :group 'whitespace)
+ 
  (defcustom whitespace-style
    '(face
      tabs spaces trailing lines space-before-tab newline
***************
*** 392,411 ****
  
  It's a list containing some or all of the following values:
  
!    face			enable all visualization via faces (see below).
  
     trailing		trailing blanks are visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in `whitespace-style'.
  
!    tabs			TABs are visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in `whitespace-style'.
  
     spaces		SPACEs and HARD SPACEs are visualized via
  			faces.
  			It has effect only if `face' (see above)
! 			is present in `whitespace-style'.
  
     lines		lines which have columns beyond
  			`whitespace-line-column' are highlighted via
--- 452,471 ----
  
  It's a list containing some or all of the following values:
  
!    face		enable all visualization via faces (see below).
  
     trailing		trailing blanks are visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in whitespace style.
  
!    tabs		TABs are visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in whitespace style.
  
     spaces		SPACEs and HARD SPACEs are visualized via
  			faces.
  			It has effect only if `face' (see above)
! 			is present in whitespace style.
  
     lines		lines which have columns beyond
  			`whitespace-line-column' are highlighted via
*************** It's a list containing some or all of th
*** 414,420 ****
  			It has precedence over `lines-tail' (see
  			below).
  			It has effect only if `face' (see above)
! 			is present in `whitespace-style'.
  
     lines-tail		lines which have columns beyond
  			`whitespace-line-column' are highlighted via
--- 474,480 ----
  			It has precedence over `lines-tail' (see
  			below).
  			It has effect only if `face' (see above)
! 			is present in whitespace style.
  
     lines-tail		lines which have columns beyond
  			`whitespace-line-column' are highlighted via
*************** It's a list containing some or all of th
*** 422,497 ****
  			But only the part of line which goes
  			beyond `whitespace-line-column' column.
  			It has effect only if `lines' (see above)
! 			is not present in `whitespace-style'
  			and if `face' (see above) is present in
! 			`whitespace-style'.
  
     newline		NEWLINEs are visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in `whitespace-style'.
  
     empty		empty lines at beginning and/or end of buffer
  			are visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in `whitespace-style'.
  
     indentation::tab	8 or more SPACEs at beginning of line are
  			visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in `whitespace-style'.
  
     indentation::space	TABs at beginning of line are visualized via
  			faces.
  			It has effect only if `face' (see above)
! 			is present in `whitespace-style'.
  
     indentation		8 or more SPACEs at beginning of line are
  			visualized, if `indent-tabs-mode' (which see)
  			is non-nil; otherwise, TABs at beginning of
  			line are visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in `whitespace-style'.
  
!    space-after-tab::tab		8 or more SPACEs after a TAB are
  				visualized via faces.
  				It has effect only if `face' (see above)
! 				is present in `whitespace-style'.
  
     space-after-tab::space	TABs are visualized when 8 or more
  				SPACEs occur after a TAB, via faces.
  				It has effect only if `face' (see above)
! 				is present in `whitespace-style'.
  
     space-after-tab		8 or more SPACEs after a TAB are
  				visualized, if `indent-tabs-mode'
  				(which see) is non-nil; otherwise,
  				the TABs are visualized via faces.
  				It has effect only if `face' (see above)
! 				is present in `whitespace-style'.
  
     space-before-tab::tab	SPACEs before TAB are visualized via
  				faces.
  				It has effect only if `face' (see above)
! 				is present in `whitespace-style'.
  
     space-before-tab::space	TABs are visualized when SPACEs occur
  				before TAB, via faces.
  				It has effect only if `face' (see above)
! 				is present in `whitespace-style'.
  
     space-before-tab		SPACEs before TAB are visualized, if
  				`indent-tabs-mode' (which see) is
  				non-nil; otherwise, the TABs are
  				visualized via faces.
  				It has effect only if `face' (see above)
! 				is present in `whitespace-style'.
  
     space-mark		SPACEs and HARD SPACEs are visualized via
  			display table.
  
     tab-mark		TABs are visualized via display table.
  
!    newline-mark		NEWLINEs are visualized via display table.
  
  Any other value is ignored.
  
--- 482,557 ----
  			But only the part of line which goes
  			beyond `whitespace-line-column' column.
  			It has effect only if `lines' (see above)
! 			is not present in whitespace style
  			and if `face' (see above) is present in
! 			whitespace style.
  
     newline		NEWLINEs are visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in whitespace style.
  
     empty		empty lines at beginning and/or end of buffer
  			are visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in whitespace style.
  
     indentation::tab	8 or more SPACEs at beginning of line are
  			visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in whitespace style.
  
     indentation::space	TABs at beginning of line are visualized via
  			faces.
  			It has effect only if `face' (see above)
! 			is present in whitespace style.
  
     indentation		8 or more SPACEs at beginning of line are
  			visualized, if `indent-tabs-mode' (which see)
  			is non-nil; otherwise, TABs at beginning of
  			line are visualized via faces.
  			It has effect only if `face' (see above)
! 			is present in whitespace style.
  
!    space-after-tab::tab	8 or more SPACEs after a TAB are
  				visualized via faces.
  				It has effect only if `face' (see above)
! 				is present in whitespace style.
  
     space-after-tab::space	TABs are visualized when 8 or more
  				SPACEs occur after a TAB, via faces.
  				It has effect only if `face' (see above)
! 				is present in whitespace style.
  
     space-after-tab		8 or more SPACEs after a TAB are
  				visualized, if `indent-tabs-mode'
  				(which see) is non-nil; otherwise,
  				the TABs are visualized via faces.
  				It has effect only if `face' (see above)
! 				is present in whitespace style.
  
     space-before-tab::tab	SPACEs before TAB are visualized via
  				faces.
  				It has effect only if `face' (see above)
! 				is present in whitespace style.
  
     space-before-tab::space	TABs are visualized when SPACEs occur
  				before TAB, via faces.
  				It has effect only if `face' (see above)
! 				is present in whitespace style.
  
     space-before-tab		SPACEs before TAB are visualized, if
  				`indent-tabs-mode' (which see) is
  				non-nil; otherwise, the TABs are
  				visualized via faces.
  				It has effect only if `face' (see above)
! 				is present in whitespace style.
  
     space-mark		SPACEs and HARD SPACEs are visualized via
  			display table.
  
     tab-mark		TABs are visualized via display table.
  
!    newline-mark	NEWLINEs are visualized via display table.
  
  Any other value is ignored.
  
*************** If nil, don't visualize TABs, (HARD) SPA
*** 499,508 ****
  via display table.
  
  There is an evaluation order for some values, if they are
! included in `whitespace-style' list.  For example, if
! indentation, indentation::tab and/or indentation::space are
! included in `whitespace-style' list.  The evaluation order for
! these values is:
  
   * For indentation:
     1. indentation
--- 559,567 ----
  via display table.
  
  There is an evaluation order for some values, if they are
! present, for example if indentation, indentation::tab and/or
! indentation::space are included.  The evaluation order for these
! values is:
  
   * For indentation:
     1. indentation
*************** these values is:
*** 520,564 ****
     3. space-before-tab::space
  
  So, for example, if indentation and indentation::space are
! included in `whitespace-style' list, the indentation value is
! evaluated instead of indentation::space value.
  
  One reason for not visualize spaces via faces (if `face' is not
! included in `whitespace-style') is to use exclusively for
  cleaning up a buffer.  See `whitespace-cleanup' and
  `whitespace-cleanup-region' for documentation.
  
  See also `whitespace-display-mappings' for documentation."
!   :type '(repeat :tag "Kind of Blank"
! 		 (choice :tag "Kind of Blank Face"
! 			 (const :tag "(Face) Face visualization"
! 				face)
! 			 (const :tag "(Face) Trailing TABs, SPACEs and HARD SPACEs"
! 				trailing)
! 			 (const :tag "(Face) SPACEs and HARD SPACEs"
! 				spaces)
! 			 (const :tag "(Face) TABs" tabs)
! 			 (const :tag "(Face) Lines" lines)
! 			 (const :tag "(Face) SPACEs before TAB"
! 				space-before-tab)
! 			 (const :tag "(Face) NEWLINEs" newline)
! 			 (const :tag "(Face) Indentation SPACEs"
! 				indentation)
! 			 (const :tag "(Face) Empty Lines At BOB And/Or EOB"
! 				empty)
! 			 (const :tag "(Face) SPACEs after TAB"
! 				space-after-tab)
! 			 (const :tag "(Mark) SPACEs and HARD SPACEs"
! 				space-mark)
! 			 (const :tag "(Mark) TABs" tab-mark)
! 			 (const :tag "(Mark) NEWLINEs" newline-mark)))
    :group 'whitespace)
  
  
  (defcustom whitespace-space 'whitespace-space
    "Symbol face used to visualize SPACE.
  
! Used when `whitespace-style' includes the value `spaces'."
    :type 'face
    :group 'whitespace)
  
--- 579,621 ----
     3. space-before-tab::space
  
  So, for example, if indentation and indentation::space are
! included, the indentation value is evaluated instead of
! indentation::space value.
  
  One reason for not visualize spaces via faces (if `face' is not
! included in whitespace style) is to use exclusively for
  cleaning up a buffer.  See `whitespace-cleanup' and
  `whitespace-cleanup-region' for documentation.
  
+ Whitespace determines which style to use on a specific buffer by
+ trying a match from `whitespace-file-style', then from
+ `whitespace-mode-style' and then by falling back to this
+ variable.
+ 
  See also `whitespace-display-mappings' for documentation."
!   :type whitespace-style-custom-type
    :group 'whitespace)
  
+ (defun whitespace-style ()
+   "Determine which style to use on current buffer."
+   (let (match)
+     (when buffer-file-name
+       (let ((styles whitespace-file-style)
+ 	    style)
+ 	(while (and (not match) (setq style (pop styles)))
+ 	  (when (string-match (car style) buffer-file-name)
+ 	    (setq match style)))))
+     (unless match
+       (setq match (assoc major-mode whitespace-mode-style)))
+     (if match
+ 	(cdr match)
+       whitespace-style)))
+ 
  
  (defcustom whitespace-space 'whitespace-space
    "Symbol face used to visualize SPACE.
  
! Used when whitespace style includes the value `spaces'."
    :type 'face
    :group 'whitespace)
  
*************** Used when `whitespace-style' includes th
*** 576,582 ****
  (defcustom whitespace-hspace 'whitespace-hspace
    "Symbol face used to visualize HARD SPACE.
  
! Used when `whitespace-style' includes the value `spaces'."
    :type 'face
    :group 'whitespace)
  
--- 633,639 ----
  (defcustom whitespace-hspace 'whitespace-hspace
    "Symbol face used to visualize HARD SPACE.
  
! Used when whitespace style includes the value `spaces'."
    :type 'face
    :group 'whitespace)
  
*************** Used when `whitespace-style' includes th
*** 594,600 ****
  (defcustom whitespace-tab 'whitespace-tab
    "Symbol face used to visualize TAB.
  
! Used when `whitespace-style' includes the value `tabs'."
    :type 'face
    :group 'whitespace)
  
--- 651,657 ----
  (defcustom whitespace-tab 'whitespace-tab
    "Symbol face used to visualize TAB.
  
! Used when whitespace style includes the value `tabs'."
    :type 'face
    :group 'whitespace)
  
*************** Used when `whitespace-style' includes th
*** 614,620 ****
  
  See `whitespace-display-mappings'.
  
! Used when `whitespace-style' includes the values `newline-mark'
  and `newline'."
    :type 'face
    :group 'whitespace)
--- 671,677 ----
  
  See `whitespace-display-mappings'.
  
! Used when whitespace style includes the values `newline-mark'
  and `newline'."
    :type 'face
    :group 'whitespace)
*************** See `whitespace-display-mappings'."
*** 637,643 ****
  (defcustom whitespace-trailing 'whitespace-trailing
    "Symbol face used to visualize trailing blanks.
  
! Used when `whitespace-style' includes the value `trailing'."
    :type 'face
    :group 'whitespace)
  
--- 694,700 ----
  (defcustom whitespace-trailing 'whitespace-trailing
    "Symbol face used to visualize trailing blanks.
  
! Used when whitespace style includes the value `trailing'."
    :type 'face
    :group 'whitespace)
  
*************** Used when `whitespace-style' includes th
*** 655,661 ****
  
  See `whitespace-line-column'.
  
! Used when `whitespace-style' includes the value `line'."
    :type 'face
    :group 'whitespace)
  
--- 712,718 ----
  
  See `whitespace-line-column'.
  
! Used when whitespace style includes the value `line'."
    :type 'face
    :group 'whitespace)
  
*************** See `whitespace-line-column'."
*** 672,678 ****
  (defcustom whitespace-space-before-tab 'whitespace-space-before-tab
    "Symbol face used to visualize SPACEs before TAB.
  
! Used when `whitespace-style' includes the value `space-before-tab'."
    :type 'face
    :group 'whitespace)
  
--- 729,735 ----
  (defcustom whitespace-space-before-tab 'whitespace-space-before-tab
    "Symbol face used to visualize SPACEs before TAB.
  
! Used when whitespace style includes the value `space-before-tab'."
    :type 'face
    :group 'whitespace)
  
*************** Used when `whitespace-style' includes th
*** 687,693 ****
  (defcustom whitespace-indentation 'whitespace-indentation
    "Symbol face used to visualize 8 or more SPACEs at beginning of line.
  
! Used when `whitespace-style' includes the value `indentation'."
    :type 'face
    :group 'whitespace)
  
--- 744,750 ----
  (defcustom whitespace-indentation 'whitespace-indentation
    "Symbol face used to visualize 8 or more SPACEs at beginning of line.
  
! Used when whitespace style includes the value `indentation'."
    :type 'face
    :group 'whitespace)
  
*************** Used when `whitespace-style' includes th
*** 702,708 ****
  (defcustom whitespace-empty 'whitespace-empty
    "Symbol face used to visualize empty lines at beginning and/or end of buffer.
  
! Used when `whitespace-style' includes the value `empty'."
    :type 'face
    :group 'whitespace)
  
--- 759,765 ----
  (defcustom whitespace-empty 'whitespace-empty
    "Symbol face used to visualize empty lines at beginning and/or end of buffer.
  
! Used when whitespace style includes the value `empty'."
    :type 'face
    :group 'whitespace)
  
*************** Used when `whitespace-style' includes th
*** 717,723 ****
  (defcustom whitespace-space-after-tab 'whitespace-space-after-tab
    "Symbol face used to visualize 8 or more SPACEs after TAB.
  
! Used when `whitespace-style' includes the value `space-after-tab'."
    :type 'face
    :group 'whitespace)
  
--- 774,780 ----
  (defcustom whitespace-space-after-tab 'whitespace-space-after-tab
    "Symbol face used to visualize 8 or more SPACEs after TAB.
  
! Used when whitespace style includes the value `space-after-tab'."
    :type 'face
    :group 'whitespace)
  
*************** visualize only HARD SPACEs between TABs.
*** 753,759 ****
  NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
        Use exactly one pair of enclosing \\\\( and \\\\).
  
! Used when `whitespace-style' includes `spaces'."
    :type '(regexp :tag "HARD SPACE Chars")
    :group 'whitespace)
  
--- 810,816 ----
  NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
        Use exactly one pair of enclosing \\\\( and \\\\).
  
! Used when whitespace style includes `spaces'."
    :type '(regexp :tag "HARD SPACE Chars")
    :group 'whitespace)
  
*************** visualize leading and/or trailing SPACEs
*** 775,781 ****
  NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
        Use exactly one pair of enclosing \\\\( and \\\\).
  
! Used when `whitespace-style' includes `spaces'."
    :type '(regexp :tag "SPACE Chars")
    :group 'whitespace)
  
--- 832,838 ----
  NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
        Use exactly one pair of enclosing \\\\( and \\\\).
  
! Used when whitespace style includes `spaces'."
    :type '(regexp :tag "SPACE Chars")
    :group 'whitespace)
  
*************** visualize leading and/or trailing TABs.
*** 797,803 ****
  NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
        Use exactly one pair of enclosing \\\\( and \\\\).
  
! Used when `whitespace-style' includes `tabs'."
    :type '(regexp :tag "TAB Chars")
    :group 'whitespace)
  
--- 854,860 ----
  NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
        Use exactly one pair of enclosing \\\\( and \\\\).
  
! Used when whitespace style includes `tabs'."
    :type '(regexp :tag "TAB Chars")
    :group 'whitespace)
  
*************** that should be considered blank.
*** 815,821 ****
  NOTE: Enclose always by \"\\\\(\" and \"\\\\)$\" the elements to highlight.
        Use exactly one pair of enclosing elements above.
  
! Used when `whitespace-style' includes `trailing'."
    :type '(regexp :tag "Trailing Chars")
    :group 'whitespace)
  
--- 872,878 ----
  NOTE: Enclose always by \"\\\\(\" and \"\\\\)$\" the elements to highlight.
        Use exactly one pair of enclosing elements above.
  
! Used when whitespace style includes `trailing'."
    :type '(regexp :tag "Trailing Chars")
    :group 'whitespace)
  
*************** If you're using `mule' package, there ma
*** 830,836 ****
  
  that should be considered blank.
  
! Used when `whitespace-style' includes `space-before-tab',
  `space-before-tab::tab' or  `space-before-tab::space'."
    :type '(regexp :tag "SPACEs Before TAB")
    :group 'whitespace)
--- 887,893 ----
  
  that should be considered blank.
  
! Used when whitespace style includes `space-before-tab',
  `space-before-tab::tab' or  `space-before-tab::space'."
    :type '(regexp :tag "SPACEs Before TAB")
    :group 'whitespace)
*************** If you're using `mule' package, there ma
*** 851,857 ****
  
  that should be considered blank.
  
! Used when `whitespace-style' includes `indentation',
  `indentation::tab' or  `indentation::space'."
    :type '(cons (regexp :tag "Indentation SPACEs")
  	       (regexp :tag "Indentation TABs"))
--- 908,914 ----
  
  that should be considered blank.
  
! Used when whitespace style includes `indentation',
  `indentation::tab' or  `indentation::space'."
    :type '(cons (regexp :tag "Indentation SPACEs")
  	       (regexp :tag "Indentation TABs"))
*************** If you're using `mule' package, there ma
*** 868,874 ****
  
  that should be considered blank.
  
! Used when `whitespace-style' includes `empty'."
    :type '(regexp :tag "Empty Lines At Beginning Of Buffer")
    :group 'whitespace)
  
--- 925,931 ----
  
  that should be considered blank.
  
! Used when whitespace style includes `empty'."
    :type '(regexp :tag "Empty Lines At Beginning Of Buffer")
    :group 'whitespace)
  
*************** If you're using `mule' package, there ma
*** 883,889 ****
  
  that should be considered blank.
  
! Used when `whitespace-style' includes `empty'."
    :type '(regexp :tag "Empty Lines At End Of Buffer")
    :group 'whitespace)
  
--- 940,946 ----
  
  that should be considered blank.
  
! Used when whitespace style includes `empty'."
    :type '(regexp :tag "Empty Lines At End Of Buffer")
    :group 'whitespace)
  
*************** If you're using `mule' package, there ma
*** 903,909 ****
  
  that should be considered blank.
  
! Used when `whitespace-style' includes `space-after-tab',
  `space-after-tab::tab' or `space-after-tab::space'."
    :type '(regexp :tag "SPACEs After TAB")
    :group 'whitespace)
--- 960,966 ----
  
  that should be considered blank.
  
! Used when whitespace style includes `space-after-tab',
  `space-after-tab::tab' or `space-after-tab::space'."
    :type '(regexp :tag "SPACEs After TAB")
    :group 'whitespace)
*************** Used when `whitespace-style' includes `s
*** 915,921 ****
  It must be an integer or nil.  If nil, the `fill-column' variable value is
  used.
  
! Used when `whitespace-style' includes `lines' or `lines-tail'."
    :type '(choice :tag "Line Length Limit"
  		 (integer :tag "Line Length")
  		 (const :tag "Use fill-column" nil))
--- 972,978 ----
  It must be an integer or nil.  If nil, the `fill-column' variable value is
  used.
  
! Used when whitespace style includes `lines' or `lines-tail'."
    :type '(choice :tag "Line Length Limit"
  		 (integer :tag "Line Length")
  		 (const :tag "Use fill-column" nil))
*************** VECTOR	is a vector of characters to be d
*** 969,975 ****
  The NEWLINE character is displayed using the face given by
  `whitespace-newline' variable.
  
! Used when `whitespace-style' includes `tab-mark', `space-mark' or
  `newline-mark'."
    :type '(repeat
  	  (list :tag "Character Mapping"
--- 1026,1032 ----
  The NEWLINE character is displayed using the face given by
  `whitespace-newline' variable.
  
! Used when whitespace style includes `tab-mark', `space-mark' or
  `newline-mark'."
    :type '(repeat
  	  (list :tag "Character Mapping"
*************** C++ modes only."
*** 1016,1026 ****
  			      (symbol :tag "Mode"))))
    :group 'whitespace)
  
  
  (defcustom whitespace-action nil
!   "Specify which action is taken when a buffer is visited or written.
  
! It's a list containing some or all of the following values:
  
     nil			no action is taken.
  
--- 1073,1137 ----
  			      (symbol :tag "Mode"))))
    :group 'whitespace)
  
+ (defconst whitespace-action-custom-type
+   '(choice :tag "Actions"
+ 	   (const :tag "None" nil)
+ 	   (repeat :tag "Action List"
+ 		   (choice :tag "Action"
+ 			   (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 "Warn If Read-Only"
+ 				  warn-if-read-only))))
+   ;; Custom type specification for Whitespace actions. Used in
+   ;; WHITESPACE-FILE-ACTION, WHITESPACE-MODE-ACTION and
+   ;; WHITESPACE-ACTION.
+   )
+ 
+ (defcustom whitespace-file-action nil
+   "File-specific actions to take when a buffer is visited or written.
+ 
+ This is a list of elements of the form (REGEXP ACTION...) where
+ REGEXP is matched against file names.  For a list of possible
+ ACTIONs, see `whitespace-action'.
+ 
+ Whitespace determines which actions need to be taken on a
+ specific buffer by trying a match from this variable, then from
+ `whitespace-mode-action' and then by falling back to
+ `whitespace-action'."
+   :type `(repeat (cons :value ("")
+ 		       (regexp :tag "File Name Matching")
+ 		       ,whitespace-action-custom-type))
+   :version "24.3"
+   :group 'whitespace)
+ 
+ (defcustom whitespace-mode-action nil
+   "Mode-specific actions to take when a buffer is visited or written.
+ 
+ This is a list of elements of the form (MODE ACTION...) where
+ MODE is a major mode name.  For a list of possible ACTIONs, see
+ `whitespace-action'.
+ 
+ Whitespace determines which actions need to be taken on a
+ specific buffer by trying a match from `whitespace-file-action',
+ then from this variable and then by falling back to
+ `whitespace-action'."
+   :type `(repeat (cons :value (fundamental-mode)
+ 		       (symbol :tag "Major Mode")
+ 		       ,whitespace-action-custom-type))
+   :version "24.3"
+   :group 'whitespace)
  
  (defcustom whitespace-action nil
!   "Default actions to take when a buffer is visited or written.
  
! Whitespace determines which actions need to be taken on a
! specific buffer by trying a match from `whitespace-file-action',
! then from `whitespace-mode-action' and then by falling back to
! this variable.
! 
! Its value is a list containing some or all of the following symbols:
  
     nil			no action is taken.
  
*************** It's a list containing some or all of th
*** 1032,1038 ****
     report-on-bogus	report if there is any bogus whitespace always
  			when local whitespace is turned on.
  
!    auto-cleanup		cleanup any bogus whitespace when buffer is
  			written.
  			See `whitespace-cleanup' and
  			`whitespace-cleanup-region'.
--- 1143,1149 ----
     report-on-bogus	report if there is any bogus whitespace always
  			when local whitespace is turned on.
  
!    auto-cleanup	cleanup any bogus whitespace when buffer is
  			written.
  			See `whitespace-cleanup' and
  			`whitespace-cleanup-region'.
*************** It's a list containing some or all of th
*** 1041,1061 ****
  			buffer is written.
  
     warn-if-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)
! 		 (repeat :tag "Action List"
! 		  (choice :tag "Action"
! 			  (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 "Warn If Read-Only" warn-if-read-only))))
    :group 'whitespace)
  
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;; User commands - Local mode
--- 1152,1179 ----
  			buffer is written.
  
     warn-if-read-only	give a warning if `cleanup' or `auto-cleanup'
! 			is present and the buffer is read-only.
  
  Any other value is treated as nil."
!   :type whitespace-action-custom-type
    :group 'whitespace)
  
+ (defun whitespace-action ()
+   "Determine which actions to take on current buffer."
+   (let (match)
+     (when buffer-file-name
+       (let ((actions whitespace-file-action)
+ 	    action)
+ 	(while (and (not match) (setq action (pop actions)))
+ 	  (when (string-match (car action) buffer-file-name)
+ 	    (setq match action)))))
+     (unless match
+       (setq match (assoc major-mode whitespace-mode-action)))
+     (if match
+ 	(cdr match)
+       whitespace-action)))
+ 
+ 
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;; User commands - Local mode
*************** See also `whitespace-newline' and `white
*** 1188,1194 ****
    :group      'whitespace
    (let ((whitespace-style '(newline-mark newline)))
      (global-whitespace-mode (if global-whitespace-newline-mode
!                                 1 -1))
      ;; sync states (running a batch job)
      (setq global-whitespace-newline-mode global-whitespace-mode)))
  
--- 1306,1312 ----
    :group      'whitespace
    (let ((whitespace-style '(newline-mark newline)))
      (global-whitespace-mode (if global-whitespace-newline-mode
! 				1 -1))
      ;; sync states (running a batch job)
      (setq global-whitespace-newline-mode global-whitespace-mode)))
  
*************** See also `whitespace-newline' and `white
*** 1220,1226 ****
      space-mark
      newline-mark
      )
!   "List of valid `whitespace-style' values.")
  
  
  (defconst whitespace-toggle-option-alist
--- 1338,1344 ----
      space-mark
      newline-mark
      )
!   "List of valid whitespace style values.")
  
  
  (defconst whitespace-toggle-option-alist
*************** SYMBOL	is a valid symbol associated with
*** 1261,1267 ****
  
  
  (defvar whitespace-active-style nil
!   "Used to save locally `whitespace-style' value.")
  
  (defvar whitespace-indent-tabs-mode indent-tabs-mode
    "Used to save locally `indent-tabs-mode' value.")
--- 1379,1385 ----
  
  
  (defvar whitespace-active-style nil
!   "Used to save locally whitespace style value.")
  
  (defvar whitespace-indent-tabs-mode indent-tabs-mode
    "Used to save locally `indent-tabs-mode' value.")
*************** Interactively, it reads one of the follo
*** 1328,1334 ****
     S	toggle SPACEs before TAB visualization
     N	toggle NEWLINE visualization
  
!    x	restore `whitespace-style' value
     ?	display brief help
  
  Non-interactively, ARG should be a symbol or a list of symbols.
--- 1446,1452 ----
     S	toggle SPACEs before TAB visualization
     N	toggle NEWLINE visualization
  
!    x	restore original whitespace style
     ?	display brief help
  
  Non-interactively, ARG should be a symbol or a list of symbols.
*************** The valid symbols are:
*** 1346,1352 ****
     indentation::tab	toggle indentation SPACEs visualization
     indentation::space	toggle indentation TABs visualization
     space-after-tab		toggle SPACEs after TAB visualization
!    space-after-tab::tab		toggle SPACEs after TAB: SPACEs visualization
     space-after-tab::space	toggle SPACEs after TAB: TABs visualization
     space-before-tab		toggle SPACEs before TAB visualization
     space-before-tab::tab	toggle SPACEs before TAB: SPACEs visualization
--- 1464,1470 ----
     indentation::tab	toggle indentation SPACEs visualization
     indentation::space	toggle indentation TABs visualization
     space-after-tab		toggle SPACEs after TAB visualization
!    space-after-tab::tab	toggle SPACEs after TAB: SPACEs visualization
     space-after-tab::space	toggle SPACEs after TAB: TABs visualization
     space-before-tab		toggle SPACEs before TAB visualization
     space-before-tab::tab	toggle SPACEs before TAB: SPACEs visualization
*************** The valid symbols are:
*** 1356,1362 ****
     space-mark		toggle SPACEs before TAB visualization
     newline-mark		toggle NEWLINE visualization
  
!    whitespace-style	restore `whitespace-style' value
  
  See `whitespace-style' and `indent-tabs-mode' for documentation."
    (interactive (whitespace-interactive-char t))
--- 1474,1480 ----
     space-mark		toggle SPACEs before TAB visualization
     newline-mark		toggle NEWLINE visualization
  
!    whitespace-style	restore original whitespace style
  
  See `whitespace-style' and `indent-tabs-mode' for documentation."
    (interactive (whitespace-interactive-char t))
*************** Interactively, it accepts one of the fol
*** 1407,1413 ****
     S	toggle SPACEs before TAB visualization
     N	toggle NEWLINE visualization
  
!    x	restore `whitespace-style' value
     ?	display brief help
  
  Non-interactively, ARG should be a symbol or a list of symbols.
--- 1525,1531 ----
     S	toggle SPACEs before TAB visualization
     N	toggle NEWLINE visualization
  
!    x	restore original whitespace style
     ?	display brief help
  
  Non-interactively, ARG should be a symbol or a list of symbols.
*************** The valid symbols are:
*** 1435,1441 ****
     space-mark		toggle SPACEs before TAB visualization
     newline-mark		toggle NEWLINE visualization
  
!    whitespace-style	restore `whitespace-style' value
  
  See `whitespace-style' and `indent-tabs-mode' for documentation."
    (interactive (whitespace-interactive-char nil))
--- 1553,1559 ----
     space-mark		toggle SPACEs before TAB visualization
     newline-mark		toggle NEWLINE visualization
  
!    whitespace-style	restore original whitespace style
  
  See `whitespace-style' and `indent-tabs-mode' for documentation."
    (interactive (whitespace-interactive-char nil))
*************** The problems cleaned up are:
*** 1466,1504 ****
  
  1. empty lines at beginning of buffer.
  2. empty lines at end of buffer.
!    If `whitespace-style' includes the value `empty', remove all
     empty lines at beginning and/or end of buffer.
  
  3. 8 or more SPACEs at beginning of line.
!    If `whitespace-style' includes the value `indentation':
     replace 8 or more SPACEs at beginning of line by TABs, if
     `indent-tabs-mode' is non-nil; otherwise, replace TABs by
     SPACEs.
!    If `whitespace-style' includes the value `indentation::tab',
     replace 8 or more SPACEs at beginning of line by TABs.
!    If `whitespace-style' includes the value `indentation::space',
     replace TABs by SPACEs.
  
  4. SPACEs before TAB.
!    If `whitespace-style' includes the value `space-before-tab':
     replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
     otherwise, replace TABs by SPACEs.
!    If `whitespace-style' includes the value
     `space-before-tab::tab', replace SPACEs by TABs.
!    If `whitespace-style' includes the value
     `space-before-tab::space', replace TABs by SPACEs.
  
  5. SPACEs or TABs at end of line.
!    If `whitespace-style' includes the value `trailing', remove
     all SPACEs or TABs at end of line.
  
  6. 8 or more SPACEs after TAB.
!    If `whitespace-style' includes the value `space-after-tab':
     replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
     otherwise, replace TABs by SPACEs.
!    If `whitespace-style' includes the value
     `space-after-tab::tab', replace SPACEs by TABs.
!    If `whitespace-style' includes the value
     `space-after-tab::space', replace TABs by SPACEs.
  
  See `whitespace-style', `indent-tabs-mode' and `tab-width' for
--- 1584,1622 ----
  
  1. empty lines at beginning of buffer.
  2. empty lines at end of buffer.
!    If whitespace style includes the value `empty', remove all
     empty lines at beginning and/or end of buffer.
  
  3. 8 or more SPACEs at beginning of line.
!    If whitespace style includes the value `indentation':
     replace 8 or more SPACEs at beginning of line by TABs, if
     `indent-tabs-mode' is non-nil; otherwise, replace TABs by
     SPACEs.
!    If whitespace style includes the value `indentation::tab',
     replace 8 or more SPACEs at beginning of line by TABs.
!    If whitespace style includes the value `indentation::space',
     replace TABs by SPACEs.
  
  4. SPACEs before TAB.
!    If whitespace style includes the value `space-before-tab':
     replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
     otherwise, replace TABs by SPACEs.
!    If whitespace style includes the value
     `space-before-tab::tab', replace SPACEs by TABs.
!    If whitespace style includes the value
     `space-before-tab::space', replace TABs by SPACEs.
  
  5. SPACEs or TABs at end of line.
!    If whitespace style includes the value `trailing', remove
     all SPACEs or TABs at end of line.
  
  6. 8 or more SPACEs after TAB.
!    If whitespace style includes the value `space-after-tab':
     replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
     otherwise, replace TABs by SPACEs.
!    If whitespace style includes the value
     `space-after-tab::tab', replace SPACEs by TABs.
!    If whitespace style includes the value
     `space-after-tab::space', replace TABs by SPACEs.
  
  See `whitespace-style', `indent-tabs-mode' and `tab-width' for
*************** documentation."
*** 1525,1531 ****
  	;; PROBLEM 1: empty lines at bob
  	;; PROBLEM 2: empty lines at eob
  	;; ACTION: remove all empty lines at bob and/or eob
! 	(when (memq 'empty whitespace-style)
  	  (let (overwrite-mode)		; enforce no overwrite
  	    (goto-char (point-min))
  	    (when (looking-at whitespace-empty-at-bob-regexp)
--- 1643,1649 ----
  	;; PROBLEM 1: empty lines at bob
  	;; PROBLEM 2: empty lines at eob
  	;; ACTION: remove all empty lines at bob and/or eob
! 	(when (memq 'empty (whitespace-style))
  	  (let (overwrite-mode)		; enforce no overwrite
  	    (goto-char (point-min))
  	    (when (looking-at whitespace-empty-at-bob-regexp)
*************** documentation."
*** 1547,1584 ****
  The problems cleaned up are:
  
  1. 8 or more SPACEs at beginning of line.
!    If `whitespace-style' includes the value `indentation':
     replace 8 or more SPACEs at beginning of line by TABs, if
     `indent-tabs-mode' is non-nil; otherwise, replace TABs by
     SPACEs.
!    If `whitespace-style' includes the value `indentation::tab',
     replace 8 or more SPACEs at beginning of line by TABs.
!    If `whitespace-style' includes the value `indentation::space',
     replace TABs by SPACEs.
  
  2. SPACEs before TAB.
!    If `whitespace-style' includes the value `space-before-tab':
     replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
     otherwise, replace TABs by SPACEs.
!    If `whitespace-style' includes the value
     `space-before-tab::tab', replace SPACEs by TABs.
!    If `whitespace-style' includes the value
     `space-before-tab::space', replace TABs by SPACEs.
  
  3. SPACEs or TABs at end of line.
!    If `whitespace-style' includes the value `trailing', remove
     all SPACEs or TABs at end of line.
  
  4. 8 or more SPACEs after TAB.
!    If `whitespace-style' includes the value `space-after-tab':
     replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
     otherwise, replace TABs by SPACEs.
!    If `whitespace-style' includes the value
     `space-after-tab::tab', replace SPACEs by TABs.
!    If `whitespace-style' includes the value
     `space-after-tab::space', replace TABs by SPACEs.
  
! See `whitespace-style', `indent-tabs-mode' and `tab-width' for
  documentation."
    (interactive "@r")
    (if buffer-read-only
--- 1665,1702 ----
  The problems cleaned up are:
  
  1. 8 or more SPACEs at beginning of line.
!    If whitespace style includes the value `indentation':
     replace 8 or more SPACEs at beginning of line by TABs, if
     `indent-tabs-mode' is non-nil; otherwise, replace TABs by
     SPACEs.
!    If whitespace style includes the value `indentation::tab',
     replace 8 or more SPACEs at beginning of line by TABs.
!    If whitespace style includes the value `indentation::space',
     replace TABs by SPACEs.
  
  2. SPACEs before TAB.
!    If whitespace style includes the value `space-before-tab':
     replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
     otherwise, replace TABs by SPACEs.
!    If whitespace style includes the value
     `space-before-tab::tab', replace SPACEs by TABs.
!    If whitespace style includes the value
     `space-before-tab::space', replace TABs by SPACEs.
  
  3. SPACEs or TABs at end of line.
!    If whitespace style includes the value `trailing', remove
     all SPACEs or TABs at end of line.
  
  4. 8 or more SPACEs after TAB.
!    If whitespace style includes the value `space-after-tab':
     replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
     otherwise, replace TABs by SPACEs.
!    If whitespace style includes the value
     `space-after-tab::tab', replace SPACEs by TABs.
!    If whitespace style includes the value
     `space-after-tab::space', replace TABs by SPACEs.
  
! See whitespace style, `indent-tabs-mode' and `tab-width' for
  documentation."
    (interactive "@r")
    (if buffer-read-only
*************** documentation."
*** 1598,1604 ****
  	   ;; ACTION: replace 8 or more SPACEs at bol by TABs, if
  	   ;; `indent-tabs-mode' is non-nil; otherwise, replace TABs
  	   ;; by SPACEs.
! 	   ((memq 'indentation whitespace-style)
  	    (let ((regexp (whitespace-indentation-regexp)))
  	      (goto-char rstart)
  	      (while (re-search-forward regexp rend t)
--- 1716,1722 ----
  	   ;; ACTION: replace 8 or more SPACEs at bol by TABs, if
  	   ;; `indent-tabs-mode' is non-nil; otherwise, replace TABs
  	   ;; by SPACEs.
! 	   ((memq 'indentation (whitespace-style))
  	    (let ((regexp (whitespace-indentation-regexp)))
  	      (goto-char rstart)
  	      (while (re-search-forward regexp rend t)
*************** documentation."
*** 1608,1625 ****
  		(unless (eolp)
  		  (indent-to tmp)))))
  	   ;; ACTION: replace 8 or more SPACEs at bol by TABs.
! 	   ((memq 'indentation::tab whitespace-style)
  	    (whitespace-replace-action
  	     'tabify rstart rend
  	     (whitespace-indentation-regexp 'tab) 0))
  	   ;; ACTION: replace TABs by SPACEs.
! 	   ((memq 'indentation::space whitespace-style)
  	    (whitespace-replace-action
  	     'untabify rstart rend
  	     (whitespace-indentation-regexp 'space) 0)))
  	  ;; PROBLEM 3: SPACEs or TABs at eol
  	  ;; ACTION: remove all SPACEs or TABs at eol
! 	  (when (memq 'trailing whitespace-style)
  	    (whitespace-replace-action
  	     'delete-region rstart rend
  	     whitespace-trailing-regexp 1))
--- 1726,1743 ----
  		(unless (eolp)
  		  (indent-to tmp)))))
  	   ;; ACTION: replace 8 or more SPACEs at bol by TABs.
! 	   ((memq 'indentation::tab (whitespace-style))
  	    (whitespace-replace-action
  	     'tabify rstart rend
  	     (whitespace-indentation-regexp 'tab) 0))
  	   ;; ACTION: replace TABs by SPACEs.
! 	   ((memq 'indentation::space (whitespace-style))
  	    (whitespace-replace-action
  	     'untabify rstart rend
  	     (whitespace-indentation-regexp 'space) 0)))
  	  ;; PROBLEM 3: SPACEs or TABs at eol
  	  ;; ACTION: remove all SPACEs or TABs at eol
! 	  (when (memq 'trailing (whitespace-style))
  	    (whitespace-replace-action
  	     'delete-region rstart rend
  	     whitespace-trailing-regexp 1))
*************** documentation."
*** 1628,1644 ****
  	   ;; ACTION: replace 8 or more SPACEs by TABs, if
  	   ;; `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)
  	     rstart rend (whitespace-space-after-tab-regexp) 1))
  	   ;; ACTION: replace 8 or more SPACEs by TABs.
! 	   ((memq 'space-after-tab::tab whitespace-style)
  	    (whitespace-replace-action
  	     'tabify rstart rend
  	     (whitespace-space-after-tab-regexp 'tab) 1))
  	   ;; ACTION: replace TABs by SPACEs.
! 	   ((memq 'space-after-tab::space whitespace-style)
  	    (whitespace-replace-action
  	     'untabify rstart rend
  	     (whitespace-space-after-tab-regexp 'space) 1)))
--- 1746,1762 ----
  	   ;; ACTION: replace 8 or more SPACEs by TABs, if
  	   ;; `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)
  	     rstart rend (whitespace-space-after-tab-regexp) 1))
  	   ;; ACTION: replace 8 or more SPACEs by TABs.
! 	   ((memq 'space-after-tab::tab (whitespace-style))
  	    (whitespace-replace-action
  	     'tabify rstart rend
  	     (whitespace-space-after-tab-regexp 'tab) 1))
  	   ;; ACTION: replace TABs by SPACEs.
! 	   ((memq 'space-after-tab::space (whitespace-style))
  	    (whitespace-replace-action
  	     'untabify rstart rend
  	     (whitespace-space-after-tab-regexp 'space) 1)))
*************** documentation."
*** 1647,1664 ****
  	   ;; ACTION: replace SPACEs before TAB by TABs, if
  	   ;; `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)
  	     rstart rend whitespace-space-before-tab-regexp
  	     (if whitespace-indent-tabs-mode 0 2)))
  	   ;; ACTION: replace SPACEs before TAB by TABs.
! 	   ((memq 'space-before-tab::tab whitespace-style)
  	    (whitespace-replace-action
  	     'tabify rstart rend
  	     whitespace-space-before-tab-regexp 0))
  	   ;; ACTION: replace TABs by SPACEs.
! 	   ((memq 'space-before-tab::space whitespace-style)
  	    (whitespace-replace-action
  	     'untabify rstart rend
  	     whitespace-space-before-tab-regexp 2)))))
--- 1765,1782 ----
  	   ;; ACTION: replace SPACEs before TAB by TABs, if
  	   ;; `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)
  	     rstart rend whitespace-space-before-tab-regexp
  	     (if whitespace-indent-tabs-mode 0 2)))
  	   ;; ACTION: replace SPACEs before TAB by TABs.
! 	   ((memq 'space-before-tab::tab (whitespace-style))
  	    (whitespace-replace-action
  	     'tabify rstart rend
  	     whitespace-space-before-tab-regexp 0))
  	   ;; ACTION: replace TABs by SPACEs.
! 	   ((memq 'space-before-tab::space (whitespace-style))
  	    (whitespace-replace-action
  	     'untabify rstart rend
  	     whitespace-space-before-tab-regexp 2)))))
*************** non-nil.
*** 1783,1789 ****
  
  If FORCE is non-nil or \\[universal-argument] was pressed just
  before calling `whitespace-report' interactively, it forces
! `whitespace-style' to have:
  
     empty
     trailing
--- 1901,1907 ----
  
  If FORCE is non-nil or \\[universal-argument] was pressed just
  before calling `whitespace-report' interactively, it forces
! whitespace style to have:
  
     empty
     trailing
*************** non-nil.
*** 1829,1835 ****
  
  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
--- 1947,1953 ----
  
  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
*************** cleaning up these problems."
*** 1865,1878 ****
    (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
--- 1983,1997 ----
    (setq force (or current-prefix-arg force))
    (save-excursion
      (save-match-data                ;FIXME: Why?
!       (let* ((style (whitespace-style))
! 	     (has-bogus nil)
  	     (rstart    (min start end))
  	     (rend      (max start end))
  	     (bogus-list
  	      (mapcar
  	       #'(lambda (option)
  		   (when force
! 		     (add-to-list 'style (car option)))
  		   (goto-char rstart)
  		   (let ((regexp
  			  (cond
*************** cleaning up these problems."
*** 1909,1916 ****
  	      (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)
--- 2028,2034 ----
  	      (forward-line 3)
  	      (dolist (option whitespace-report-list)
  		(forward-line 1)
! 		(whitespace-mark-x 27 (memq (car option) style))
  		(whitespace-mark-x 7 (car bogus-list))
  		(setq bogus-list (cdr bogus-list)))
  	      (forward-line 1)
*************** cleaning up these problems."
*** 1943,1949 ****
  (defconst whitespace-help-text
    "\
   Whitespace Toggle Options                  | scroll up  :  SPC   or > |
!                                             | scroll down:  M-SPC or < |
   FACES                                      \\__________________________/
   []  f   - toggle face visualization
   []  t   - toggle TAB visualization
--- 2061,2067 ----
  (defconst whitespace-help-text
    "\
   Whitespace Toggle Options                  | scroll up  :  SPC   or > |
! 					    | scroll down:  M-SPC or < |
   FACES                                      \\__________________________/
   []  f   - toggle face visualization
   []  t   - toggle TAB visualization
*************** cleaning up these problems."
*** 1968,1974 ****
   []  S - toggle SPACE and HARD SPACE visualization
   []  N - toggle NEWLINE visualization
  
!       x - restore `whitespace-style' value
  
        ? - display this text\n\n"
    "Text for whitespace toggle options.")
--- 2086,2092 ----
   []  S - toggle SPACE and HARD SPACE visualization
   []  N - toggle NEWLINE visualization
  
!       x - restore original whitespace style
  
        ? - display this text\n\n"
    "Text for whitespace toggle options.")
*************** It accepts one of the following chars:
*** 2092,2105 ****
     S	toggle SPACE and HARD SPACE visualization
     N	toggle NEWLINE visualization
  
!    x	restore `whitespace-style' value
     ?	display brief help
  
  See also `whitespace-toggle-option-alist'."
!   (let* ((is-off (not (if local-p
! 			  whitespace-mode
! 			global-whitespace-mode)))
! 	 (style  (cond (is-off  whitespace-style) ; use default value
  		       (local-p whitespace-active-style)
  		       (t       whitespace-toggle-style)))
  	 (prompt
--- 2210,2223 ----
     S	toggle SPACE and HARD SPACE visualization
     N	toggle NEWLINE visualization
  
!    x	restore original whitespace style
     ?	display brief help
  
  See also `whitespace-toggle-option-alist'."
!   (let* ((is-off (not (if local-p whitespace-mode global-whitespace-mode)))
! 	 (style  (cond (is-off (if local-p
! 				   (whitespace-style)
! 				 whitespace-style))
  		       (local-p whitespace-active-style)
  		       (t       whitespace-toggle-style)))
  	 (prompt
*************** ARG is a list of options to be toggled.
*** 2146,2152 ****
  THE-LIST is a list of options.  This list will be toggled and the
  resultant list will be returned."
    (unless (if local-p whitespace-mode global-whitespace-mode)
!     (setq the-list whitespace-style))
    (setq the-list (copy-sequence the-list)) ; keep original list
    (dolist (sym (if (listp arg) arg (list arg)))
      (cond
--- 2264,2270 ----
  THE-LIST is a list of options.  This list will be toggled and the
  resultant list will be returned."
    (unless (if local-p whitespace-mode global-whitespace-mode)
!     (setq the-list (if local-p (whitespace-style) whitespace-style)))
    (setq the-list (copy-sequence the-list)) ; keep original list
    (dolist (sym (if (listp arg) arg (list arg)))
      (cond
*************** resultant list will be returned."
*** 2154,2160 ****
       ((eq sym 'help-newline))
       ;; restore default values
       ((eq sym 'whitespace-style)
!       (setq the-list whitespace-style))
       ;; toggle valid values
       ((memq sym whitespace-style-value-list)
        (setq the-list (if (memq sym the-list)
--- 2272,2278 ----
       ((eq sym 'help-newline))
       ;; restore default values
       ((eq sym 'whitespace-style)
!       (setq the-list (if local-p (whitespace-style) whitespace-style)))
       ;; toggle valid values
       ((memq sym whitespace-style-value-list)
        (setq the-list (if (memq sym the-list)
*************** resultant list will be returned."
*** 2181,2189 ****
    (set (make-local-variable 'whitespace-display-table) nil)
    (set (make-local-variable 'whitespace-display-table-was-local) nil)
    (set (make-local-variable 'whitespace-active-style)
!        (if (listp whitespace-style)
! 	   whitespace-style
! 	 (list whitespace-style)))
    (set (make-local-variable 'whitespace-indent-tabs-mode)
         indent-tabs-mode)
    (set (make-local-variable 'whitespace-tab-width)
--- 2299,2307 ----
    (set (make-local-variable 'whitespace-display-table) nil)
    (set (make-local-variable 'whitespace-display-table-was-local) nil)
    (set (make-local-variable 'whitespace-active-style)
!        (if (listp (whitespace-style))
! 	   (whitespace-style)
! 	 (list (whitespace-style))))
    (set (make-local-variable 'whitespace-indent-tabs-mode)
         indent-tabs-mode)
    (set (make-local-variable 'whitespace-tab-width)
*************** Also refontify when necessary."
*** 2520,2526 ****
  	  (and whitespace-buffer-changed
  	       (or
  		;; ... or inside eob whitespace region
! 	        (>= whitespace-point whitespace-eob-marker)
  		;; ... or at eob whitespace region border
  		(and (= whitespace-point (1- whitespace-eob-marker))
  		     (= (following-char) ?\n)))))))
--- 2638,2644 ----
  	  (and whitespace-buffer-changed
  	       (or
  		;; ... or inside eob whitespace region
! 		(>= whitespace-point whitespace-eob-marker)
  		;; ... or at eob whitespace region border
  		(and (= whitespace-point (1- whitespace-eob-marker))
  		     (= (following-char) ?\n)))))))
*************** Also refontify when necessary."
*** 2579,2585 ****
  	(setq buffer-display-table (make-display-table)))
        (dolist (entry whitespace-display-mappings)
  	;; check if it is to display this mark
! 	(when (memq (car entry) whitespace-style)
  	  ;; Get a displayable mapping.
  	  (setq vecs (cddr entry))
  	  (while (and vecs
--- 2697,2703 ----
  	(setq buffer-display-table (make-display-table)))
        (dolist (entry whitespace-display-mappings)
  	;; check if it is to display this mark
! 	(when (memq (car entry) (whitespace-style))
  	  ;; Get a displayable mapping.
  	  (setq vecs (cddr entry))
  	  (while (and vecs
*************** Also refontify when necessary."
*** 2618,2635 ****
  
  (defun whitespace-action-when-on ()
    "Action to be taken always when local whitespace is turned on."
!   (cond ((memq 'cleanup whitespace-action)
  	 (whitespace-cleanup))
! 	((memq 'report-on-bogus whitespace-action)
  	 (whitespace-report nil t))))
  
  
  (defun whitespace-write-file-hook ()
    "Action to be taken when buffer is written.
  It should be added buffer-locally to `write-file-functions'."
!   (cond ((memq 'auto-cleanup whitespace-action)
  	 (whitespace-cleanup))
! 	((memq 'abort-on-bogus whitespace-action)
  	 (when (whitespace-report nil t)
  	   (error "Abort write due to whitespace problems in %s"
  		  (buffer-name)))))
--- 2736,2753 ----
  
  (defun whitespace-action-when-on ()
    "Action to be taken always when local whitespace is turned on."
!   (cond ((memq 'cleanup (whitespace-action))
  	 (whitespace-cleanup))
! 	((memq 'report-on-bogus (whitespace-action))
  	 (whitespace-report nil t))))
  
  
  (defun whitespace-write-file-hook ()
    "Action to be taken when buffer is written.
  It should be added buffer-locally to `write-file-functions'."
!   (cond ((memq 'auto-cleanup (whitespace-action))
  	 (whitespace-cleanup))
! 	((memq 'abort-on-bogus (whitespace-action))
  	 (when (whitespace-report nil t)
  	   (error "Abort write due to whitespace problems in %s"
  		  (buffer-name)))))
*************** It should be added buffer-locally to `wr
*** 2638,2644 ****
  
  (defun whitespace-warn-read-only (msg)
    "Warn if buffer is read-only."
!   (when (memq 'warn-if-read-only whitespace-action)
      (message "Can't %s: %s is read-only" msg (buffer-name))))
  
  
--- 2756,2762 ----
  
  (defun whitespace-warn-read-only (msg)
    "Warn if buffer is read-only."
!   (when (memq 'warn-if-read-only (whitespace-action))
      (message "Can't %s: %s is read-only" msg (buffer-name))))
  
  
[Message part 4 (text/plain, inline)]

-- 
ELS 2013, June 3/4, Madrid, Spain:  http://els2013.european-lisp-symposium.org

Scientific site:   http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com

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

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Didier Verna <didier <at> didierverna.net>
Cc: 13646 <at> debbugs.gnu.org, viniciusjl <at> ig.com.br
Subject: Re: bug#13646: Whitespace support for file/mode-specific styles and
	actions
Date: Thu, 07 Feb 2013 09:26:01 -0500
> the following patch extends whitespace.el with the ability to specify
> styles and actions on a file or mode specific basis.

Can't we already do that in the usual way (i.e. with file-local,
dir-local, or mode hooks settings)?


        Stefan




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

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

From: Didier Verna <didier <at> didierverna.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 13646 <at> debbugs.gnu.org, viniciusjl <at> ig.com.br
Subject: Re: bug#13646: Whitespace support for file/mode-specific styles and
	actions
Date: Thu, 07 Feb 2013 15:44:35 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

>> the following patch extends whitespace.el with the ability to specify
>> styles and actions on a file or mode specific basis.
>
> Can't we already do that in the usual way (i.e. with file-local,
> dir-local, or mode hooks settings)?

  To some extend yes, but the extension I propose is more general
  because, for example, the matching on file names is done with
  regexps. Without this, you could end up duplicating a common setting
  in several dir/file local sections.

  Another (more personal) argument, is that in general, I don't like the
  idea of having settings for a single functionality scattered all over
  the place. I prefer to see those settings in a centralized place, say
  a customization buffer.

-- 
ELS 2013, June 3/4, Madrid, Spain:  http://els2013.european-lisp-symposium.org

Scientific site:   http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com




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

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

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Didier Verna <didier <at> didierverna.net>
Cc: 13646 <at> debbugs.gnu.org, viniciusjl <at> ig.com.br
Subject: mode-specific and file-regexp-specific settings
Date: Thu, 07 Feb 2013 11:18:12 -0500
retitle 13646 Mode-specific and file-regexp-specific settings
thanks

>   Another (more personal) argument, is that in general, I don't like the
>   idea of having settings for a single functionality scattered all over
>   the place.  I prefer to see those settings in a centralized place, say
>   a customization buffer.

We all agree.  Of course this is like "the expression problem", in that
there are various ways to group settings.

I think the idea is good, but I don't think the solution should be
specific to whitespace.el.

Maybe we should instead extend dir-local settings so you can specify
a dir-local class via a regexp (and accept several dir-local classes for
a given directory, or even allow mapping a directory-regexp directly to
a set of vars without going through a class).

Also, we should introduce a way to set variables to a value that is
mode-dependent.  Maybe something like

  (setq-modes whitespace-style
     (foo-mode 'face)
     (bar-mode 'trailing)
     (t 'tab-mark))

Which could turn into something akin to

  (setq-default whitespace-style 'tab-mark)
  (add-hook 'bar-mode-hook (lambda () (setq-local whitespace-style 'trailing)))
  (add-hook 'foo-mode-hook (lambda () (setq-local whitespace-style 'face)))


        Stefan




Changed bug title to 'Mode-specific and file-regexp-specific settings' from 'Whitespace support for file/mode-specific styles and actions' Request was from Stefan Monnier <monnier <at> IRO.UMontreal.CA> to control <at> debbugs.gnu.org. (Thu, 07 Feb 2013 16:20:02 GMT) Full text and rfc822 format available.

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

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

From: Didier Verna <didier <at> didierverna.net>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 13646 <at> debbugs.gnu.org, viniciusjl <at> ig.com.br
Subject: Re: mode-specific and file-regexp-specific settings
Date: Thu, 07 Feb 2013 17:56:13 +0100
Stefan Monnier <monnier <at> IRO.UMontreal.CA> wrote:

> I think the idea is good, but I don't think the solution should be
> specific to whitespace.el.

  A general solution would be nice of course (but this is frightening;
  see below). I'm not familiar enough with the dir-local functionality
  (XEmacs doesn't have that) to comment on it though.

> Also, we should introduce a way to set variables to a value that is
> mode-dependent.  Maybe something like
>
>   (setq-modes whitespace-style
>      (foo-mode 'face)
>      (bar-mode 'trailing)
>      (t 'tab-mark))

  This looks a bit hackish. If you're going down that road and want to
  be that general, why stop here ? Someday, someone will want
  window-specific values and what not and you'll end up with tons of
  setq variants. And then, you're gonna wish you had specifiers in the
  first place (and /that/ is frightening) :-)

> Which could turn into something akin to
>
>   (setq-default whitespace-style 'tab-mark)
>   (add-hook 'bar-mode-hook (lambda () (setq-local whitespace-style 'trailing)))
>   (add-hook 'foo-mode-hook (lambda () (setq-local whitespace-style 'face)))

    Question: if you have both the above and dir-local settings, which
    ones take precedence (I hope the dir-local ones) ?

-- 
ELS 2013, June 3/4, Madrid, Spain:  http://els2013.european-lisp-symposium.org

Scientific site:   http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com




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

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

From: Didier Verna <didier <at> didierverna.net>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 13646 <at> debbugs.gnu.org, viniciusjl <at> ig.com.br
Subject: Re: mode-specific and file-regexp-specific settings
Date: Thu, 07 Feb 2013 18:25:37 +0100
Stefan Monnier <monnier <at> IRO.UMontreal.CA> wrote:

> Also, we should introduce a way to set variables to a value that is
> mode-dependent.  Maybe something like
>
>   (setq-modes whitespace-style
>      (foo-mode 'face)
>      (bar-mode 'trailing)
>      (t 'tab-mark))
>
> Which could turn into something akin to
>
>   (setq-default whitespace-style 'tab-mark)
>   (add-hook 'bar-mode-hook (lambda () (setq-local whitespace-style 'trailing)))
>   (add-hook 'foo-mode-hook (lambda () (setq-local whitespace-style 'face)))

  Oh, and BTW this is not gonna work. What you're doing here is
  instantiating buffer-local values once and for all. If later on the
  user changes his mode-specific settings, they won't be propagated to
  the already existing buffers.

  On the contrary, what I do in whitespace.el (and I think what should
  be done in a general solution) is to dynamically retreive the
  file/mode-specific value everytime it's needed, so that user changes
  are visible everywhere immediately (this is what specifiers do in
  XEmacs in fact).

-- 
ELS 2013, June 3/4, Madrid, Spain:  http://els2013.european-lisp-symposium.org

Scientific site:   http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13646; Package emacs. (Thu, 07 Feb 2013 21:48:01 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Didier Verna <didier <at> didierverna.net>
Cc: 13646 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>,
	viniciusjl <at> ig.com.br
Subject: Re: bug#13646: Whitespace support for file/mode-specific styles and
	actions
Date: Thu, 07 Feb 2013 16:47:15 -0500
Didier Verna wrote:

>   Another (more personal) argument, is that in general, I don't like the
>   idea of having settings for a single functionality scattered all over
>   the place. I prefer to see those settings in a centralized place, say
>   a customization buffer.

It hasn't been said explicitly in this report AFAICS, but you don't need
a dir-locals.el file to use directory local settings. You can do it in
.emacs with dir-locals-set-directory-class. See

http://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.htm

But the directory has to be fully specified (ie can't use regexps).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13646; Package emacs. (Thu, 07 Feb 2013 21:49:01 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Didier Verna <didier <at> didierverna.net>
Cc: 13646 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>,
	viniciusjl <at> ig.com.br
Subject: Re: bug#13646: Whitespace support for file/mode-specific styles and
	actions
Date: Thu, 07 Feb 2013 16:48:41 -0500
Glenn Morris wrote:

> http://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.htm

s/htm$/html/




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

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

From: Didier Verna <didier <at> didierverna.net>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 13646 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>,
	viniciusjl <at> ig.com.br
Subject: Re: bug#13646: Whitespace support for file/mode-specific styles and
	actions
Date: Thu, 07 Feb 2013 23:00:02 +0100
Glenn Morris <rgm <at> gnu.org> wrote:

> It hasn't been said explicitly in this report AFAICS, but you don't
> need a dir-locals.el file to use directory local settings. You can do
> it in .emacs with dir-locals-set-directory-class. See

  Yes indeed (I since read the relevant documentation). The problems
  that remain, AFAUI, are

   1/ as you said, the (current) lack of support for regexp-based dir
   (or file, for that matter) specification,
   2/ the fact that eventually, the settings turn into buffer-local
   variables.

   Also, correct me if I'm wrong but I think that Custom is totally
   unaware of the dir-locals feature, so this is less user-friendly than
   a package-specific solution.

-- 
ELS 2013, June 3/4, Madrid, Spain:  http://els2013.european-lisp-symposium.org

Scientific site:   http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13646; Package emacs. (Tue, 12 Feb 2013 08:56:02 GMT) Full text and rfc822 format available.

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

From: Didier Verna <didier <at> didierverna.net>
To: Glenn Morris <rgm <at> gnu.org>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
	13646 <at> debbugs.gnu.org, viniciusjl <at> ig.com.br
Subject: Re: bug#13646: Whitespace support for file/mode-specific styles and
	actions
Date: Tue, 12 Feb 2013 09:55:29 +0100
I wrote:

>   Yes indeed (I since read the relevant documentation). The problems
>   that remain, AFAUI, are
>
>    1/ as you said, the (current) lack of support for regexp-based dir
>    (or file, for that matter) specification,
>    2/ the fact that eventually, the settings turn into buffer-local
>    variables.
>
>    Also, correct me if I'm wrong but I think that Custom is totally
>    unaware of the dir-locals feature, so this is less user-friendly than
>    a package-specific solution.

  I tried to play a little more with dir-locals and I see yet another
  limitation: it seems that there's no way to accumulate values across
  settings for different directories in the same tree.

  For example, I may create a class CLASS in my init file with some
  variable settings for it, and put "/usr/local/" in that
  class. However, since "/usr/local/src/emacs/emacs.git" has a
  .dir-locals.el file, my settings for "/usr/local" won't apply.

  Stefan, is there a chance to see my whitespace.el modifications
  applied eventually ?

-- 
Resistance is futile. You will be jazzimilated.

Scientific site:   http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13646; Package emacs. (Tue, 12 Feb 2013 14:11:03 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Didier Verna <didier <at> didierverna.net>
Cc: Glenn Morris <rgm <at> gnu.org>, 13646 <at> debbugs.gnu.org, viniciusjl <at> ig.com.br
Subject: Re: bug#13646: Whitespace support for file/mode-specific styles and
	actions
Date: Tue, 12 Feb 2013 09:10:21 -0500
>   I tried to play a little more with dir-locals and I see yet another
>   limitation: it seems that there's no way to accumulate values across
>   settings for different directories in the same tree.

>   For example, I may create a class CLASS in my init file with some
>   variable settings for it, and put "/usr/local/" in that
>   class. However, since "/usr/local/src/emacs/emacs.git" has a
>   .dir-locals.el file, my settings for "/usr/local" won't apply.

Indeed, it's another current limitation.  It'd be good to lift it.

>   Stefan, is there a chance to see my whitespace.el modifications
>   applied eventually ?

I really would much rather improve the generic settings code.
But as for your specific patch, it's up to the whitespace.el maintainer.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13646; Package emacs. (Tue, 12 Feb 2013 14:18:01 GMT) Full text and rfc822 format available.

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

From: Didier Verna <didier <at> didierverna.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Glenn Morris <rgm <at> gnu.org>, 13646 <at> debbugs.gnu.org, viniciusjl <at> ig.com.br
Subject: Re: bug#13646: Whitespace support for file/mode-specific styles and
	actions
Date: Tue, 12 Feb 2013 15:17:28 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:

> I really would much rather improve the generic settings code.

  I understand. Looks like a lot of work though, and in the meantime, I
  don't think it hurts to have a workaround, even package-specific.

> But as for your specific patch, it's up to the whitespace.el maintainer.

  OK. No life sign yet.

-- 
Resistance is futile. You will be jazzimilated.

Scientific site:   http://www.lrde.epita.fr/~didier
Music (Jazz) site: http://www.didierverna.com




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13646; Package emacs. (Tue, 12 Feb 2013 17:02:01 GMT) Full text and rfc822 format available.

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

From: Christopher Schmidt <christopher <at> ch.ristopher.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#13646: Whitespace support for file/mode-specific styles and
	actions
Date: Tue, 12 Feb 2013 17:00:41 +0000 (GMT)
Didier Verna <didier <at> didierverna.net> writes:
> Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>
>> I really would much rather improve the generic settings code.
>
> I understand. Looks like a lot of work though, and in the meantime, I
> don't think it hurts to have a workaround, even package-specific.

-1

Having three user options that take precedence upon each other, with a
subset of them being safe local variables, is scary.  This can break
regular user setups and third party packages big time.  Even worse, the
work around your workaround is not trivial.

I do not see any need for such an intrusive change in the first place.
You can easily implement what you did there using find-file-hook,
after-change-major-mode-hook in combination with an independent global
minor mode.

        Christopher




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#13646; Package emacs. (Fri, 18 Sep 2020 14:39:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#13646: Whitespace support for file/mode-specific styles and
 actions
Date: Fri, 18 Sep 2020 16:38:11 +0200
Christopher Schmidt <christopher <at> ch.ristopher.com> writes:

>>> I really would much rather improve the generic settings code.
>>
>> I understand. Looks like a lot of work though, and in the meantime, I
>> don't think it hurts to have a workaround, even package-specific.
>
> -1
>
> Having three user options that take precedence upon each other, with a
> subset of them being safe local variables, is scary.  This can break
> regular user setups and third party packages big time.  Even worse, the
> work around your workaround is not trivial.
>
> I do not see any need for such an intrusive change in the first place.
> You can easily implement what you did there using find-file-hook,
> after-change-major-mode-hook in combination with an independent global
> minor mode.

It seems like there was little enthusiasm for this feature --
Christopher sums up the objections well, so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 18 Sep 2020 14:39:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 13646 <at> debbugs.gnu.org and Didier Verna <didier <at> didierverna.net> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 18 Sep 2020 14:39: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, 17 Oct 2020 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 182 days ago.

Previous Next


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