emacs-devel
[Top][All Lists]
Advanced

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

Re: turning on minor modes from hooks


From: Geoff Gole
Subject: Re: turning on minor modes from hooks
Date: Fri, 4 Sep 2009 14:23:02 -0700

>> What about some kind of enable-minor-mode function?

> If you mean a generic function that can enable specific minor modes,
> that will just cause proliferation of definitions like

> (defun turn-on-auto-fill () (enable-minor-mode 'auto-fill-mode))
> (defun turn-off-auto-fill () (disable-minor-mode 'auto-fill-mode))

Not necessarily. It could return a function suitable for inclusion in a hook:

 (defun turn-on (minor-mode-symbol)
     `(lambda () (,minor-mode-symbol t)))

  (add-hook 'foo-mode-hook (turn-on 'some-minor-mode))

Or maybe

  (defun turn-on (&rest minor-mode-symbols)
    `(lambda () ,@(mapcar (lambda (sym) (list sym t))
                          minor-mode-symbols)))

  (add-hook 'foo-mode-hook (turn-on 'foo-minor-mode 'bar-minor-mode))

Excuse the fake lexical scoping hack. turn-on is probably also not the
right name, as (turn-on 'mode) not turning on any mode might be
confusing.




reply via email to

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