Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #207388 > unrolled thread
| Started by | Pétùr <peturvilj@gmail.com> |
|---|---|
| First post | 2019-04-12 18:10 +0200 |
| Last post | 2019-05-07 06:40 +0200 |
| Articles | 9 — 5 participants |
Back to article view | Back to linux.debian.user
emacs save and kill buffer for (neo)mutt Pétùr <peturvilj@gmail.com> - 2019-04-12 18:10 +0200
Re: emacs save and kill buffer for (neo)mutt David Wright <deblis@lionunicorn.co.uk> - 2019-04-12 20:10 +0200
Re: emacs save and kill buffer for (neo)mutt Pétùr <peturvilj@gmail.com> - 2019-04-29 10:40 +0200
Re: emacs save and kill buffer for (neo)mutt David Wright <deblis@lionunicorn.co.uk> - 2019-04-29 17:50 +0200
Re: emacs save and kill buffer for (neo)mutt Pétùr <peturvilj@gmail.com> - 2019-05-07 06:20 +0200
Detour: notmuch advertisement (was: emacs save and kill buffer for (neo)mutt) Peter Wiersig <peter@friesenpeter.de> - 2019-04-13 01:50 +0200
Re: Detour: notmuch advertisement John Hasler <jhasler@newsguy.com> - 2019-04-13 02:10 +0200
Re: Detour: notmuch advertisement 황병희 <soyeomul@red-october.yw.doraji.xyz> - 2019-04-13 03:50 +0200
Re: Detour: notmuch advertisement (was: emacs save and kill buffer for (neo)mutt) Pétùr <peturvilj@gmail.com> - 2019-05-07 06:40 +0200
| From | Pétùr <peturvilj@gmail.com> |
|---|---|
| Date | 2019-04-12 18:10 +0200 |
| Subject | emacs save and kill buffer for (neo)mutt |
| Message-ID | <xM6Ux-6hs-1@gated-at.bofh.it> |
I use neomutt with emacs.
I would like to quickly save and kill a buffer in emacs. This is to
avoid typing C-x C-s and, then, C-x C-c when sending an email. I want
one shortcut to save and kill the buffer and be back quickly in mutt to
send the email.
I tried the following inside my .emacs (binded to C-q). It works but
kill also the window when inside a terminal. I am not going back to mutt
after writing inside emacs (-nw) and C-q. How can I fix that?
;; Kill the current buffer immediatly, saving it if needed.
(defvar kill-save-buffer-delete-windows t
"*Delete windows when `kill-save-buffer' is used.
If this is non-nil, then `kill-save-buffer' will also delete the corresponding
windows. This is inverted by `kill-save-buffer' when called with a prefix.")
(defun kill-save-buffer (arg)
"Save the current buffer (if needed) and then kill it.
Also, delete its windows according to `kill-save-buffer-delete-windows'.
A prefix argument ARG reverses this behavior."
(interactive "P")
(let ((del kill-save-buffer-delete-windows))
(when arg (setq del (not del)))
(when (and (buffer-file-name) (not (file-directory-p (buffer-file-name))))
(save-buffer))
(let ((buf (current-buffer)))
(when del (delete-windows-on buf))
(kill-buffer buf))))
(global-set-key (kbd "C-q") 'kill-save-buffer)
[toc] | [next] | [standalone]
| From | David Wright <deblis@lionunicorn.co.uk> |
|---|---|
| Date | 2019-04-12 20:10 +0200 |
| Message-ID | <xM8MF-7rk-7@gated-at.bofh.it> |
| In reply to | #207388 |
On Fri 12 Apr 2019 at 18:04:45 (+0200), Pétùr wrote: > I use neomutt with emacs. > > I would like to quickly save and kill a buffer in emacs. This is to > avoid typing C-x C-s and, then, C-x C-c when sending an email. I want > one shortcut to save and kill the buffer and be back quickly in mutt to > send the email. > > I tried the following inside my .emacs (binded to C-q). It works but > kill also the window when inside a terminal. I am not going back to mutt > after writing inside emacs (-nw) and C-q. How can I fix that? I just put (global-set-key [?\C-q] "\C-x\C-s\C-x\C-c") into my ~/.emacs file and it works just as one would expect, both when emacs is running in a separate window (which disappears) or when emacs is running with -nw in an xterm (the xterm is unaffected). I will finish composing this email (in emacs -nw) by typing ^q and expect to be left in mutt, whereupon I shall press y to send it. Is that what you wnat? Here goes … > ;; Kill the current buffer immediatly, saving it if needed. > (defvar kill-save-buffer-delete-windows t > "*Delete windows when `kill-save-buffer' is used. > If this is non-nil, then `kill-save-buffer' will also delete the corresponding > windows. This is inverted by `kill-save-buffer' when called with a prefix.") > (defun kill-save-buffer (arg) > "Save the current buffer (if needed) and then kill it. > Also, delete its windows according to `kill-save-buffer-delete-windows'. > A prefix argument ARG reverses this behavior." > (interactive "P") > (let ((del kill-save-buffer-delete-windows)) > (when arg (setq del (not del))) > (when (and (buffer-file-name) (not (file-directory-p (buffer-file-name)))) > (save-buffer)) > (let ((buf (current-buffer))) > (when del (delete-windows-on buf)) > (kill-buffer buf)))) > > (global-set-key (kbd "C-q") 'kill-save-buffer) > Cheers, David.
[toc] | [prev] | [next] | [standalone]
| From | Pétùr <peturvilj@gmail.com> |
|---|---|
| Date | 2019-04-29 10:40 +0200 |
| Message-ID | <xS9Zn-84Z-1@gated-at.bofh.it> |
| In reply to | #207393 |
On 12/04/19 13:00, David Wright wrote: >On Fri 12 Apr 2019 at 18:04:45 (+0200), Pétùr wrote: >> I use neomutt with emacs. >> >> I would like to quickly save and kill a buffer in emacs. This is to >> avoid typing C-x C-s and, then, C-x C-c when sending an email. I want >> one shortcut to save and kill the buffer and be back quickly in mutt to >> send the email. >> >> I tried the following inside my .emacs (binded to C-q). It works but >> kill also the window when inside a terminal. I am not going back to mutt >> after writing inside emacs (-nw) and C-q. How can I fix that? > >I just put >(global-set-key [?\C-q] "\C-x\C-s\C-x\C-c") >into my ~/.emacs file and it works just as one would expect, both when >emacs is running in a separate window (which disappears) or when emacs >is running with -nw in an xterm (the xterm is unaffected). > >I will finish composing this email (in emacs -nw) by typing ^q and >expect to be left in mutt, whereupon I shall press y to send it. >Is that what you wnat? (Sorry for the late reply) Yes, this is exactly what I want to do. (global-set-key [?\C-q] "\C-x\C-s\C-x\C-c") works as expected when emacs is launched as an instance. But I use it as a daemon. When emacs is launched by "emacs --daemon" and called by emacsclient, your shortcut will kill the buffer and I am not going back to mutt. I have to dig into my tmp folder to retrieve the email I was trying to send. The same behavior occures with the code I use. (see first email). How can I prevent this? Pétùr
[toc] | [prev] | [next] | [standalone]
| From | David Wright <deblis@lionunicorn.co.uk> |
|---|---|
| Date | 2019-04-29 17:50 +0200 |
| Message-ID | <xSgHw-3L9-11@gated-at.bofh.it> |
| In reply to | #207969 |
On Mon 29 Apr 2019 at 10:38:40 (+0200), Pétùr wrote: > On 12/04/19 13:00, David Wright wrote: > > On Fri 12 Apr 2019 at 18:04:45 (+0200), Pétùr wrote: > > > I use neomutt with emacs. > > > > > > I would like to quickly save and kill a buffer in emacs. This is to > > > avoid typing C-x C-s and, then, C-x C-c when sending an email. I want > > > one shortcut to save and kill the buffer and be back quickly in mutt to > > > send the email. > > > > > > I tried the following inside my .emacs (binded to C-q). It works but > > > kill also the window when inside a terminal. I am not going back to mutt > > > after writing inside emacs (-nw) and C-q. How can I fix that? > > > > I just put > > (global-set-key [?\C-q] "\C-x\C-s\C-x\C-c") > > into my ~/.emacs file and it works just as one would expect, both when > > emacs is running in a separate window (which disappears) or when emacs > > is running with -nw in an xterm (the xterm is unaffected). > > > > I will finish composing this email (in emacs -nw) by typing ^q and > > expect to be left in mutt, whereupon I shall press y to send it. > > Is that what you wnat? > > (Sorry for the late reply) > > Yes, this is exactly what I want to do. > > (global-set-key [?\C-q] "\C-x\C-s\C-x\C-c") works as expected when emacs > is launched as an instance. But I use it as a daemon. When emacs is > launched by "emacs --daemon" and called by emacsclient, your shortcut > will kill the buffer and I am not going back to mutt. I have to dig into > my tmp folder to retrieve the email I was trying to send. > > The same behavior occures with the code I use. (see first email). > > How can I prevent this? Use the correct means of exiting emacs, perhaps. The key sequences I have used (^X^S^X^C, and the same keys but using ^Q shortcut) will work if the emacsclient instance is in a different frame from the emacs server. Because I use emacs -nw for composing emails¹, and the server was running in a different xterm, it all worked. OTOH if you're using emacs in its own window, then typically your email composition will jump to that same window too. In which case, typing ^X^C will shut down the emacs server itself. You should be using ^X# instead, to exit just that buffer. So for you, it would be (global-set-key [?\C-q] "\C-x\C-s\C-x#") for the definition. ^X# is meant to signal the calling program that it's completed its editing work. ¹ Why? For historical reasons. I used to type emails on a slow, unreliable laptop, with mutt running on a server. Opening an X window for emacs was also slow, so I ran it non-windowed. Cheers, David.
[toc] | [prev] | [next] | [standalone]
| From | Pétùr <peturvilj@gmail.com> |
|---|---|
| Date | 2019-05-07 06:20 +0200 |
| Message-ID | <xUZK9-7bf-1@gated-at.bofh.it> |
| In reply to | #207980 |
Thanks. In fact my code was working, but the terminal I used (xfce4-terminal) has a built-in shortcut for "quit" binded to Ctrl+q. This is why Emacs, when launched inside xfce4-terminal, closes instead of going back to mutt. Silly...
[toc] | [prev] | [next] | [standalone]
| From | Peter Wiersig <peter@friesenpeter.de> |
|---|---|
| Date | 2019-04-13 01:50 +0200 |
| Subject | Detour: notmuch advertisement (was: emacs save and kill buffer for (neo)mutt) |
| Message-ID | <xMe5H-29y-1@gated-at.bofh.it> |
| In reply to | #207388 |
Pétùr <peturvilj@gmail.com> writes: > I use neomutt with emacs. If you're using the kitchen sink, why not stay completely in emacs? https://emacs.stackexchange.com/q/12927 (Disclaimer: I wrote one of the answers to that meta question) I used mutt for decades, I still think it's a fine tool, but I found more happiness in my chosen "notmuch" mail setup. David & the bunch are doing a terrific job with the project as whole and the debian packages in focus, and even if you're building the project directly from the repository, it's no bother with dabian (even stable). What I gained by dropping mutt was an uninterupted access to the rest of my life in emacs, and the user interface is streamlined to hundreds or thousands of replied messages a day. A I finish this post, the next keypress will be C-c C-c like many other emacs modes, which will send the mail to the list, bury the buffer and redisplay the search results, where I filtered for debian-user and unread before. Yours, Peter
[toc] | [prev] | [next] | [standalone]
| From | John Hasler <jhasler@newsguy.com> |
|---|---|
| Date | 2019-04-13 02:10 +0200 |
| Subject | Re: Detour: notmuch advertisement |
| Message-ID | <xMep3-2vN-3@gated-at.bofh.it> |
| In reply to | #207415 |
Peter writes: > If you're using the kitchen sink, why not stay completely in emacs? Right. Use Gnus. -- John Hasler jhasler@newsguy.com Elmwood, WI USA
[toc] | [prev] | [next] | [standalone]
| From | 황병희 <soyeomul@red-october.yw.doraji.xyz> |
|---|---|
| Date | 2019-04-13 03:50 +0200 |
| Subject | Re: Detour: notmuch advertisement |
| Message-ID | <xMfXP-3h1-1@gated-at.bofh.it> |
| In reply to | #207416 |
On Fri, Apr 12 2019, John Hasler wrote: > Peter writes: >> If you're using the kitchen sink, why not stay completely in emacs? > > Right. Use Gnus. Me too, Gnus is it!!! Sincerely, Byung-Hee. -- ^고맙습니다 _地平天成_ 감사합니다_^))//
[toc] | [prev] | [next] | [standalone]
| From | Pétùr <peturvilj@gmail.com> |
|---|---|
| Date | 2019-05-07 06:40 +0200 |
| Subject | Re: Detour: notmuch advertisement (was: emacs save and kill buffer for (neo)mutt) |
| Message-ID | <xV03v-7ky-1@gated-at.bofh.it> |
| In reply to | #207415 |
On 13/04/19 01:43, Peter Wiersig wrote:
>Pétùr <peturvilj@gmail.com> writes:
>
>> I use neomutt with emacs.
>
>If you're using the kitchen sink, why not stay completely in emacs?
>https://emacs.stackexchange.com/q/12927
>(Disclaimer: I wrote one of the answers to that meta question)
>
>I used mutt for decades, I still think it's a fine tool, but I found
>more happiness in my chosen "notmuch" mail setup. David & the bunch are
>doing a terrific job with the project as whole and the debian packages
>in focus, and even if you're building the project directly from the
>repository, it's no bother with dabian (even stable).
>
>What I gained by dropping mutt was an uninterupted access to the rest of
>my life in emacs, and the user interface is streamlined to hundreds or
>thousands of replied messages a day.
>
>A I finish this post, the next keypress will be C-c C-c like many other
>emacs modes, which will send the mail to the list, bury the buffer and
>redisplay the search results, where I filtered for debian-user and
>unread before.
Thanks, I will definitly consider using notmuch inside emacs. I already
have my email fetched by offlineimap and I use mutt-notmuch inside mutt to
search email (with the code below).
I have some work to do (for example, I have some difficulty with
notmuch's spirit of doing everything with a search; for now I am unable
to display only my inbox inside notmuch-emacs...).
#######################
# Notmuch integration #
#######################
macro index,pager <F8> \
"<enter-command>unset wait_key<enter><shell-escape>notmuch-mutt --prompt search<enter><change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>" \
"notmuch: search mail"
macro index,pager <F9> \
"<enter-command>unset wait_key<enter><pipe-message>notmuch-mutt thread<enter><change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter><enter-command>set wait_key<enter>" \
"notmuch: reconstruct thread"
macro index,pager <F6> \
"<enter-command>unset wait_key<enter><pipe-message>notmuch-mutt tag -inbox<enter>" \
"notmuch: remove message from inbox"
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web