help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How make server-edit (an emacsclient function) NOT ask to confirm if


From: Emanuel Berg
Subject: Re: How make server-edit (an emacsclient function) NOT ask to confirm if I really want to save?
Date: Sat, 26 Mar 2016 20:09:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Chris Seberino <cseberino@gmail.com> writes:

> Thanks for the reply. Here's more context. I wrote
> my own version control system for fun. To check in
> code, I first invoke a command to start a Mercurial
> shell command. Apparently to save my commit message,
> and finish checking in the code, you need to use
> server-edit.
>
> Does that change anything? Would those hooks you
> mentioned still be the way to go?

You'll have to check the documentation for each one.

In general, if you want something automatized at
command or event E, first see if there are any related
hooks, "after-E-hook", "before-E-hook", and the like.

If there are, put your stuff there, e.g.,

    ;; (setq text-mode-hook nil)
    (defun text-mode-hook-f ()
      (auto-fill-mode)
      (abbrev-mode) )
    (add-hook 'text-mode-hook #'text-mode-hook-f)

If there aren't any hooks, you can either use
so-called advices (which is "function composition" in
CS lingo). Place your stuff before or after E, which
you must isolate to one particular function. It can
help to put the new stuff in a function as well, e.g.,

    (defun gnus-summary-insert-all (&rest unused)
      (gnus-summary-insert-old-articles t) )
    (advice-add       'gnus-summary-limit-to-subject :before 
#'gnus-summary-insert-all)
    (advice-add       'gnus-summary-limit-to-author  :before 
#'gnus-summary-insert-all)
    ;; (advice-remove 'gnus-summary-limit-to-subject         
#'gnus-summary-insert-all)
    ;; (advice-remove 'gnus-summary-limit-to-author          
#'gnus-summary-insert-all)

Either that, or, which I think is simpler and less
error-prone, you can do your own function:

    (defun do-E-with-my-modification ()
      (interactive)
      (do-my-stuff)
      (E) ) ; or use `call-interactively' here for complete transparence

Then bind "do-E-with-my-modification" to a shortcut
and start using that instead. If you didn't use the
old shortcut to call E hundreds of times already, you
can assign a new shortcut to your modified version.
If old habits die hard, it is not a deadly sin to
overwrite the old one :)

-- 
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
                   - so far: 19 Blogomatic articles -                   




reply via email to

[Prev in Thread] Current Thread [Next in Thread]