[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why adding this write-file-hook makes save-buffer not work anymore!?
From: |
Joakim Hove |
Subject: |
Re: Why adding this write-file-hook makes save-buffer not work anymore!?? |
Date: |
Fri, 29 Aug 2003 10:24:05 +0200 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.2 (gnu/linux) |
seberino@spawar.navy.mil (Christian Seberino) writes:
> Thanks for your help. What makes my function return non-nil
> and how do I make it return nil???
The last evaluated statement of your function is the return value,
i.e. in your function the return value is the result of:
(goto-char original-pos)
The documentation of (goto-char ) does not say, but the little test
function:
(defun testit ()
(interactive)
(message "Point-max: %s" (goto-char (point-max))) (sleep-for 5)
(message "Point-min: %s" (goto-char (point-min))) (sleep-for 5))
quickly reveals that (goto-char ) returns the value of the point it
has moved to (at least when it succeeds), i.e. the value of
original-pos in your case.
>> > (defun cs-delete-trailing-whitespace() (interactive)
>> > (delete-trailing-whitespace)
>> > (let ((original-pos (point)))
>> > (goto-char (point-max))
>> > (delete-blank-lines)
>> > (goto-char original-pos)))
To return 'nil just change the last lines:
;; snip
(goto-char original-pos)
'nil))
HTH - Joakim
--
/--------------------------------------------------------------------\
/ Joakim Hove / hove@bccs.no / (55 5) 84076 | \
| Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
| CMU | 5231 Paradis |
\ Thormøhlensgt.55, 5020 Bergen. | 55 91 28 18 /
\--------------------------------------------------------------------/