* 2 different initialization strategies
@ 2023-01-17 23:46 Davin Pearson
2023-01-18 0:11 ` Emanuel Berg
2023-01-18 0:24 ` [External] : " Drew Adams
0 siblings, 2 replies; 3+ messages in thread
From: Davin Pearson @ 2023-01-17 23:46 UTC (permalink / raw)
To: help-gnu-emacs
I have the following hook defined.
(defun dmp-php-hook ()
(when (eq major-mode 'html-mode)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\\([ \t]+$\\)" nil t)
(delete-region (match-beginning 1) (match-end 1))
))
nil))
I have two different initialisation strategies:
(1) (add-hook 'write-file-functions 'dmp-write-mode-function
(2) (setq write-file-functions (cons 'dmp-write-mode-function
'write-file-functions))
With add-hook I can specify the optional variable DEPTH
for that version so I prefer this strategy over the other
one, if it is allowed.
*Davin.*
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 2 different initialization strategies
2023-01-17 23:46 2 different initialization strategies Davin Pearson
@ 2023-01-18 0:11 ` Emanuel Berg
2023-01-18 0:24 ` [External] : " Drew Adams
1 sibling, 0 replies; 3+ messages in thread
From: Emanuel Berg @ 2023-01-18 0:11 UTC (permalink / raw)
To: help-gnu-emacs
Davin Pearson wrote:
> I have the following hook defined.
>
> (defun dmp-php-hook ()
> (when (eq major-mode 'html-mode)
> (save-excursion
> (goto-char (point-min))
> (while (re-search-forward "\\([ \t]+$\\)" nil t)
> (delete-region (match-beginning 1) (match-end 1))
> ))
> nil))
Add `delete-trailing-whitespace' to `before-save-hook' ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [External] : 2 different initialization strategies
2023-01-17 23:46 2 different initialization strategies Davin Pearson
2023-01-18 0:11 ` Emanuel Berg
@ 2023-01-18 0:24 ` Drew Adams
1 sibling, 0 replies; 3+ messages in thread
From: Drew Adams @ 2023-01-18 0:24 UTC (permalink / raw)
To: Davin Pearson, help-gnu-emacs@gnu.org
> I have the following hook defined.
>
> (defun dmp-php-hook ()
> (when (eq major-mode 'html-mode)
> (save-excursion
> (goto-char (point-min))
> (while (re-search-forward "\\([ \t]+$\\)" nil t)
> (delete-region (match-beginning 1) (match-end 1))
> ))
> nil))
>
> I have two different initialisation strategies:
>
> (1) (add-hook 'write-file-functions 'dmp-write-mode-function
>
> (2) (setq write-file-functions (cons 'dmp-write-mode-function
> 'write-file-functions))
>
> With add-hook I can specify the optional variable DEPTH
> for that version so I prefer this strategy over the other
> one, if it is allowed.
(What's the question?)
Yes, use `add-hook' to add a hook function.
Don't use `setq'.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-18 0:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-17 23:46 2 different initialization strategies Davin Pearson
2023-01-18 0:11 ` Emanuel Berg
2023-01-18 0:24 ` [External] : " Drew Adams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).