bug#4069: 23.1.50; whitespace.el

"Craig Falls" <[email protected]>
Newsgroups gmane.emacs.bugs,gmane.emacs.pretest.bugs
Message-ID <[email protected]>
There is a problem with whitespace-cleanup, when called before
whitespace-turn-on.  The buffer-local variable
whitespace-indentation-regexp doesn't get updated to correspond to the
buffer-local value of indent-tabs-mode.  This means that even if
indent-tabs-mode is nil, a line with text following a single tab
character will not be converted into a line of text following 8 space
characters when whitespace-cleanup is called.  There is a simple
work-around -- just turn whitespace on and off again to set the
buffer-local variables:

(defun my-whitespace-cleanup ()
  "Fixes a bug in whitespace-cleanup in which buffer-local
indent-tabs-mode is not respected."
  (interactive)
  (whitespace-turn-on) ;; sets buffer-local variables
  (whitespace-turn-off) ;; don't actually want the mode to be on
  (whitespace-cleanup))

Here are instructions to replicate the problem:

Start up with no .emacs.  Set indent-tabs-mode to nil.  Make sure
'indentation is in whitespace-style.  Insert a tab character into a
buffer with no spaces after it, e.g. the line could be "\tfoo".  Run
whitespace-cleanup in the buffer.  Note that the tab character is still
there.  Now run my-whitespace-cleanup.  Note that the tab character has
been replaced by spaces.

The fact that indent-tabs-mode is buffer-local is important.  For
example, makefile-mode sets it to true since tabs are a necessary part
of the syntax of make files.

In GNU Emacs 23.1.50.8 (x86_64-unknown-linux-gnu, GTK+ Version 2.10.4)
 of 2009-08-03 on nyc-qws-005
Windowing system distributor `The X.Org Foundation', version 11.0.70101000
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: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: GNUmakefile

Minor modes in effect:
  shell-dirtrack-mode: t
  flyspell-mode: t
  desktop-save-mode: t
  diff-auto-refine-mode: t
  partial-completion-mode: t
  dynamic-completion-mode: t
  show-paren-mode: t
  recentf-mode: t
  iswitchb-mode: t
  global-auto-revert-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  global-auto-composition-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

Load-path shadows:
/mnt/global/dev/lib/elisp/inf-caml hides /mnt/global/dev/lib/elisp/caml-mode/inf-caml
/mnt/global/dev/lib/elisp/tuareg-mode/camldebug hides /mnt/global/dev/lib/elisp/caml-mode/camldebug
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.