[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Suggestions for improvements to the *Completions* buffer
From: |
Philip Kaludercic |
Subject: |
Re: Suggestions for improvements to the *Completions* buffer |
Date: |
Fri, 17 Dec 2021 11:27:55 +0000 |
Juri Linkov <juri@linkov.net> writes:
>>> - (define-key map "z" 'kill-current-buffer)
>>> (define-key map "\M-g\M-c" 'switch-to-minibuffer)
>>> + (define-key map "z" #'completion-kill-buffer)
>>> + (define-key map [remap keyboard-quit] #'completion-quit)
>>> + (define-key map [remap quit-window] #'switch-to-minibuffer)
>>
>> It seems that remapping quit-window to switch-to-minibuffer creates
>> issues when the completion buffer is not invoked by the minibuffer, but
>> e.g. by complete-symbol. Binding it to completion-quit (defined above)
>> instead, might actually be more natural, as "q"/quit-window is expected
>> to close a window.
>
> Good point, so `q' should not be rebound from its standard command
> `quit-window'. Like you noticed, currently `quit-window' fails
> to select the minibuffer window, but this is a bug, so this regression
> was reported in bug#52491.
Ok, great!
> Then "z" could be bound to a variant of `quit-window'
> that calls it with the argument KILL non-nil.
So something like this?
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index bd8aa611e9..95e7abdeae 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -78,6 +78,19 @@ smtpmail-smtp-server
"The name of the host running SMTP server."
:type '(choice (const nil) string))
+(defcustom smtpmail-smtp-server-alist '()
+ "Alist of SMTP servers for different addresses."
+ :type '(alist :key-type
+ (string :tag "Sender")
+ :value-type
+ (list (string :tag "SMTP Server")
+ (natnum :tag "Service")
+ (choice :tag "Stream type"
+ (const :tag "Possibly upgrade to STARTTLS" nil)
+ (const :tag "Always use STARTTLS" starttls)
+ (const :tag "Never use STARTTLS" plain)
+ (const :tag "Use TLS/SSL" ssl)))))
+
(defcustom smtpmail-smtp-service 25
"SMTP service port number.
The default value would be \"smtp\" or 25."
@@ -706,13 +719,9 @@ smtpmail-user-mail-address
(defun smtpmail-via-smtp (recipient smtpmail-text-buffer
&optional ask-for-password
send-attempts)
- (unless smtpmail-smtp-server
+ (unless (or smtpmail-smtp-server smtpmail-smtp-server-alist)
(smtpmail-query-smtp-server))
- (let ((process nil)
- (send-attempts (or send-attempts 1))
- (host (or smtpmail-smtp-server
- (error "`smtpmail-smtp-server' not defined")))
- (port smtpmail-smtp-service)
+ (let* ((process nil)
;; `smtpmail-mail-address' should be set to the appropriate
;; buffer-local value by the caller, but in case not:
(envelope-from
@@ -727,6 +736,14 @@ smtpmail-via-smtp
(and from
(cadr (mail-extract-address-components from))))
(smtpmail-user-mail-address))))
+ (send-attempts (or send-attempts 1))
+ (server (alist-get envelope-from smtpmail-smtp-server-alist
+ (list smtpmail-smtp-server)
+ nil #'string=))
+ (host (or (car server)
+ (error "No known SMTP Server for %S" envelope-from)))
+ (port (or (cadr server)
+ smtpmail-smtp-service))
process-buffer
result
auth-mechanisms
@@ -757,7 +774,7 @@ smtpmail-via-smtp
(setq result
(open-network-stream
"smtpmail" process-buffer host port
- :type smtpmail-stream-type
+ :type (or (caddr server) smtpmail-stream-type)
:return-list t
:warn-unless-encrypted ask-for-password
:capability-command (format "EHLO %s\r\n" (smtpmail-fqdn))
> Like currently `ESC ESC ESC' can close the completion window
> by the special command `delete-completion-window', then the same
> command could be bound to `[remap keyboard-quit]' as well.
Sure, but what noticeable difference does this make? It seems to me
that quitting or killing the completion buffer doesn't amount to much of
a difference, as *Completion* is rarely selected manually.
The only case I can think of where the difference could matter, is when
*Completion* is so large that you need to kill it. But considering that
even with "C-h o TAB" the difference appears to be indistinguishable.
Quitting a window and requesting the came completion doesn't even reuse
the existing buffer.
>> The question is whether or not there is a need for a separate
>> switch-to-minibuffer binding (besides M-g M-c)? Is keeping the
>> completions buffer active while returning to the minibuffer a real need?
>
> Good question. If four key bindings (q, z, C-g, ESC ESC ESC)
> all will close the completions (first two using quit-window,
> and last two using delete-completion-window), then maybe we should have
> an easy-to-type keybinding that will switch to the minibuffer without
> closing the completions window?
>
> There is an easy-to-type keys <PgUp> and M-v to switch to the
> completions window, but no an easy-to-type key to switch back.
>
> It seems wrong for `q' to switch to the minibuffer without closing
> the window because `quit-window' implies that window should quit.
> But what key to use instead, I have no idea.
Seeing as <left> and <right> are bound to previous-completion and
next-completion, maybe <up> and <down> could be used for
completion/minibuffer switching?
Or to take inspiration from Protesilaos's MCT package, that switches
back to the minibuffer once next-completion and previous-completion
reaches the end/beginning of the buffer, without quitting the window.
With next-completion bound to TAB while TAB also jumps back to the
completion buffer, it would behave to just by cycling.
--
Philip Kaludercic
- Re: [External] : Suggestions for improvements to the *Completions* buffer, (continued)
Re: Suggestions for improvements to the *Completions* buffer, Philip Kaludercic, 2021/12/13
- Re: Suggestions for improvements to the *Completions* buffer, Juri Linkov, 2021/12/14
- Re: Suggestions for improvements to the *Completions* buffer,
Philip Kaludercic <=
- Re: Suggestions for improvements to the *Completions* buffer, Philip Kaludercic, 2021/12/17
- Re: Suggestions for improvements to the *Completions* buffer, Philip Kaludercic, 2021/12/18
- Re: Suggestions for improvements to the *Completions* buffer, Po Lu, 2021/12/18
- Re: Suggestions for improvements to the *Completions* buffer, Philip Kaludercic, 2021/12/18
- Re: Suggestions for improvements to the *Completions* buffer, Po Lu, 2021/12/19
Re: Suggestions for improvements to the *Completions* buffer, Juri Linkov, 2021/12/18
Re: Suggestions for improvements to the *Completions* buffer, Philip Kaludercic, 2021/12/19
Re: Suggestions for improvements to the *Completions* buffer, Juri Linkov, 2021/12/19
Re: Suggestions for improvements to the *Completions* buffer, Philip Kaludercic, 2021/12/19
Re: Suggestions for improvements to the *Completions* buffer, Philip Kaludercic, 2021/12/20