[comp.emacs] cursor movement at buffer start-up

mesard@bbn.com (Wayne Mesard) (03/12/88)

When the following function is executed courtesy of set-auto-mode
the end-of-line call gets undone because the body of set-auto-mode is
embedded in a save-excursion.  (At least, I'm 99% sure that that's the
reason.)

(defun mail-mode ()
  "Mode for composing a mail message."
  (interactive)
  (setq major-mode 'mail-mode)
  (setq mode-name "WMail")
  (use-local-map mail-mode-map)
  (if (= (point) (point-min))
      (end-of-line)))

The end-of-line does work when mail-mode is invoked interactively.
Also, the following command line does the right thing:

	emacs foo.file  -f end-of-line

(I'm not sure where -f's args are executed, but it's apparently just
before the switch-buffer, and obviosuly not inside a save-excursion.)

My question is: what can be done?  Is there a way to schedule cursor
movements so that they will be executed later on?  (Too bad run-hooks
doesn't do this.)

(BTW, all this nonsense is so the cursor appears at the end of the "To: " 
line when a message composition window appears.)

Thanks in advance.

-- 
Wayne Mesard   | "The people of the North End don't like the city telling us
MESARD@BBN.COM | where and when we can and can't park our cars.  So as soon
BBN Labs,      | as they fix the meters, we jam em and break em, and paint em.
Cambridge, MA  | We call it a local referendum."  -JS