Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been using emacs for years, but I'm relatively new to customizing lisp (beyond plugging in lines from other emacs scripts / package installation instructions). I programmed scheme before, so I'm somewhat familiar, but that was also a long time ago.

How do I map a key to more than one operation? I'm adapting the cycle font sizes lisp code form: http://www.emacswiki.org/emacs/CycleFontSizes

except that I would like to maximize the window (I'm using mac OSX) after font resizing.

I can maximize the window using maxframe:

(require 'maxframe)
(add-hook 'window-setup-hook 'maximize-frame t)

How do I add this to the font size key bindings. I'd like to do something like:

(define-key global-map (read-kbd-macro "C-0")   
  (lambda()
    'font-zoom-reset-font-size
    (add-hook 'window-setup-hook 'maximize-frame t))
)

This isn't correct because define-key is expecting a different type. This is probably pretty trivial after seeing an example...

share|improve this question

Update

You're very close -- just need to define your function as being interactive by including the one line (interactive) and make the call to font-zoom-reset-font-size actually call the function, not just a reference to the function:

(define-key global-map (read-kbd-macro "C-0")   
  (lambda()
    (interactive)
    (font-zoom-reset-font-size)
    (add-hook 'window-setup-hook 'maximize-frame t))
)

Original (and still valid) answer

You can define a function with your multiple steps and then bind the key to that function. Something like:

(defun zoom-font-and-max()
  (interactive)
  (font-zoom-reset-font-size)
  (add-hook 'window-setup-hook 'maximize-frame t))


(global-set-key (kbd "C-0") 'zoom-font-and-max)
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .