help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to apply a minor mode to all buffers


From: Eli Zaretskii
Subject: Re: How to apply a minor mode to all buffers
Date: Mon, 22 Jan 2007 23:23:29 +0200

> From: "Robert Thorpe" <address@hidden>
> Date: 22 Jan 2007 03:48:30 -0800
> 
> The after-change-mode-hook is still quite tedious.
> Let's say you want to enable hide-show mode in every mode in which it's
> useful.  Generally it's only useful in programming language modes and a
> few text modes, currently the only way to accurately do this is to
> enable it individually in many hooks.

Here's a simple solution to a similar problem I have in my .emacs for
quite some time:

    ;;; Turn on trailing whitespace highlighting in modes where
    ;;; it makes sense.
    (let* ((twh-modes '("texinfo-mode" "makefile-mode" "c-mode-common"
                        "emacs-lisp-mode" "outline-mode" "sh-mode"
                        "shell-script-mode" 
                        ))
           (elt (car twh-modes)))
      (while elt
        (add-hook (intern (concat elt "-hook"))
                  (function (lambda ()
                              (setq show-trailing-whitespace t))))
        (setq twh-modes (cdr twh-modes)
              elt (car twh-modes))))

If I ever need to do that in an additional mode, all I have to do is
add another mode name to the list at the beginning of this snippet:
hardly a tedious job.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]