all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Compacting calls to add-hook
@ 2008-07-03 14:55 Nordlöw
  2008-07-03 15:55 ` weber
  2008-07-03 16:19 ` Juanma Barranquero
  0 siblings, 2 replies; 3+ messages in thread
From: Nordlöw @ 2008-07-03 14:55 UTC (permalink / raw
  To: help-gnu-emacs

Can we make the following repetitive code more compact (perhaps using
a map-function)?:

    (add-hook 'c-mode-hook '(lambda () (outline-minor-mode t)))
    (add-hook 'c++-mode-hook '(lambda () (outline-minor-mode t)))
    (add-hook 'text-mode-hook '(lambda () (outline-minor-mode t)))
    (add-hook 'emacs-lisp-mode-hook '(lambda () (outline-minor-mode
t)))
    (add-hook 'sh-mode-hook '(lambda () (outline-minor-mode t)))2
    (add-hook 'octave-mode-hook '(lambda () (outline-minor-mode t)))
    (add-hook 'matlab-mode-hook '(lambda () (outline-minor-mode t)))
    (add-hook 'help-mode-hook '(lambda () (outline-minor-mode t)))
    (add-hook 'info-mode-hook '(lambda () (outline-minor-mode t)))

/Nordlöw


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Compacting calls to add-hook
  2008-07-03 14:55 Compacting calls to add-hook Nordlöw
@ 2008-07-03 15:55 ` weber
  2008-07-03 16:19 ` Juanma Barranquero
  1 sibling, 0 replies; 3+ messages in thread
From: weber @ 2008-07-03 15:55 UTC (permalink / raw
  To: help-gnu-emacs

On Jul 3, 11:55 am, Nordlöw <per.nord...@gmail.com> wrote:
> Can we make the following repetitive code more compact (perhaps using
> a map-function)?:
>
>     (add-hook 'c-mode-hook '(lambda () (outline-minor-mode t)))
>     (add-hook 'c++-mode-hook '(lambda () (outline-minor-mode t)))
>     (add-hook 'text-mode-hook '(lambda () (outline-minor-mode t)))
>     (add-hook 'emacs-lisp-mode-hook '(lambda () (outline-minor-mode
> t)))
>     (add-hook 'sh-mode-hook '(lambda () (outline-minor-mode t)))2
>     (add-hook 'octave-mode-hook '(lambda () (outline-minor-mode t)))
>     (add-hook 'matlab-mode-hook '(lambda () (outline-minor-mode t)))
>     (add-hook 'help-mode-hook '(lambda () (outline-minor-mode t)))
>     (add-hook 'info-mode-hook '(lambda () (outline-minor-mode t)))
>
> /Nordlöw

You mean something like this ?

(mapc (lambda (x) (add-hook x (lambda () (outline-minor-mode t))))
	  '(vhdl-mode-hook lua-mode-hook))

I'm curious about how you're using outline-minor-mode with all those
modes.
Cheers,
weber


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Compacting calls to add-hook
  2008-07-03 14:55 Compacting calls to add-hook Nordlöw
  2008-07-03 15:55 ` weber
@ 2008-07-03 16:19 ` Juanma Barranquero
  1 sibling, 0 replies; 3+ messages in thread
From: Juanma Barranquero @ 2008-07-03 16:19 UTC (permalink / raw
  To: Nordlöw; +Cc: help-gnu-emacs

On Thu, Jul 3, 2008 at 16:55, Nordlöw <per.nordlow@gmail.com> wrote:
> Can we make the following repetitive code more compact (perhaps using
> a map-function)?:

What do you mean, "can we"? It's trivial:

(let ((func (lambda () (outline-minor-mode 1))))
  (dolist (hook '(c-mode-hook c++-mode-hook text-mode-hook
                  emacs-lisp-mode-hook sh-mode-hook octave-mode-hook
                  matlab-mode-hook help-mode-hook info-mode-hook))
    (add-hook hook func)))

though I'm not sure that's optimizing for readability...

   Juanma

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-03 16:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-03 14:55 Compacting calls to add-hook Nordlöw
2008-07-03 15:55 ` weber
2008-07-03 16:19 ` Juanma Barranquero

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.