unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: Utkarsh Singh <utkarsh190601@gmail.com>,
	Notmuch mailing list <notmuch@notmuchmail.org>
Subject: Re: [PATCH] emacs: Add more front ends for address completion
Date: Wed, 09 Feb 2022 23:59:20 +0200	[thread overview]
Message-ID: <m2v8xnn1l3.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <87bkzhbez9.fsf@gmail.com>

On Tue, Feb 08 2022, Utkarsh Singh wrote:

> Hello maintainers,
>
> Emacs Lisp Package Archive (ELPA) now includes a package called 'corfu',
> according to its documentation:
>
>         Corfu enhances the default completion in region function with a
>         completion overlay. The current candidates are shown in a popup
>         below or above the point.  Corfu is the minimalistic
>         ~completion-in-region~ counterpart of the
>         [[https://github.com/minad/vertico][Vertico]] minibuffer UI.
>
> Hence, this patch tries to add support for `completion-in-region' in
> `notmuch-address-expand-name'.  By default, this behaviour is turned off
> so that existing users can enjoy existing completion techniques.

The current "default" (i.e. w/o any notmuch emacs mua configuration) is to
use completing-read to do the completion. If "company" is available, then
company is used by default (w/ all address harvesting and so on...). 

This is "messy" enough ;( (i.e the notmuch-address-selection-function
is called if company mode is not available or notmuch-address-command
is a string instead of 'internal or 'as-is (or whatnot, too tired to do
deep investigation there ;/)

This change, contributes even more "complexity" there. To keep the
complexity to the same level would be adding more
notmuch-address-selection-functions and have the defcustom there list
the options (also probably the name of notmuch-address-selection-function
would need to be changed to notmuch-fallback-address-selection-function
;/)

Also, if name was notmuch-address-selection-function but its interface
changed, current users using their own functions (I am in that list)
would get error there (the interface would have to be
(defun notmuch-address-selection-function (prompt collection initial-input &optional beg end)
to be backward compatible)
If name was changed then their own function would not be used -- which is 
OK, things change and users can read from NEWS how to be compatible
again...

All this said, I think this is not simple to solve, as this otherwise fine
change would indicate :/

Tomi

>
> Thank you,
> Utkarsh Singh
> -- 
> Utkarsh Singh
> https://utkarshsingh.xyz/
> From fdc88b81fef763f7d7dcdc899aa8e90482c574fa Mon Sep 17 00:00:00 2001
> From: Utkarsh Singh <utkarsh190601@gmail.com>
> Date: Tue, 8 Feb 2022 19:17:26 +0530
> Subject: [PATCH] emacs: Add more front ends for address completion
>
> Add support for address completion through completion-in-region.
> * notmuch-address.el (notmuch-address-use-completion-in-region):
> Introduce customizable variable to activate the new front end.
> (notmuch-address-selection-function, notmuch-address-expand-name): Use
> it.
> ---
>  emacs/notmuch-address.el | 28 ++++++++++++++++++----------
>  1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
> index 1a4cdda2..cfb56a3a 100644
> --- a/emacs/notmuch-address.el
> +++ b/emacs/notmuch-address.el
> @@ -123,10 +123,10 @@ you should make sure it is not somewhere publicly readable."
>  (defcustom notmuch-address-selection-function 'notmuch-address-selection-function
>    "The function to select address from given list.
>  
> -The function is called with PROMPT, COLLECTION, and INITIAL-INPUT
> -as arguments (subset of what `completing-read' can be called
> -with).  While executed the value of `completion-ignore-case'
> -is t.  See documentation of function
> +The function is called with PROMPT, COLLECTION, INITIAL-INPUT,
> +BEG and END as arguments (subset of what `completing-read' can be
> +called with).  While executed the value of
> +`completion-ignore-case' is t.  See documentation of function
>  `notmuch-address-selection-function' to know how address
>  selection is made by default."
>    :type 'function
> @@ -150,13 +150,19 @@ matching `notmuch-address-completion-headers-regexp'."
>    :group 'notmuch-send
>    :group 'notmuch-address)
>  
> +(defcustom notmuch-address-use-completion-in-region nil
> +  "Use `completion-in-region' for address completion."
> +  :type 'boolean
> +  :group 'notmuch-send
> +  :group 'notmuch-address)
> +
>  ;;; Setup
>  
> -(defun notmuch-address-selection-function (prompt collection initial-input)
> -  "Call (`completing-read'
> -      PROMPT COLLECTION nil nil INITIAL-INPUT 'notmuch-address-history)"
> -  (completing-read
> -   prompt collection nil nil initial-input 'notmuch-address-history))
> +(defun notmuch-address-selection-function (prompt collection initial-input beg end)
> +  (if notmuch-address-use-completion-in-region
> +      (completion-in-region beg end collection)
> +    (completing-read
> +     prompt collection nil nil initial-input 'notmuch-address-history)))
>  
>  (defvar notmuch-address-completion-headers-regexp
>    "^\\(Resent-\\)?\\(To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):")
> @@ -245,7 +251,9 @@ requiring external commands."
>  		     (funcall notmuch-address-selection-function
>  			      (format "Address (%s matches): " num-options)
>  			      options
> -			      orig)))))
> +			      orig
> +			      beg
> +			      end)))))
>        (if chosen
>  	  (progn
>  	    (push chosen notmuch-address-history)
> -- 
> 2.35.1

  reply	other threads:[~2022-02-09 21:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08 14:38 [PATCH] emacs: Add more front ends for address completion Utkarsh Singh
2022-02-09 21:59 ` Tomi Ollila [this message]
2022-02-12 16:09   ` Alexander Adolf
2022-02-21 22:20     ` emacs: notmuch-address-command 'as-is throws error (was: [PATCH] emacs: Add more front ends for address completion) Alexander Adolf
2022-02-22 22:04       ` Tomi Ollila
2022-02-28 21:19         ` Alexander Adolf
2022-03-01 17:51           ` Alexander Adolf
2022-02-28  9:01     ` [PATCH] emacs: Add more front ends for address completion Utkarsh Singh
2022-03-06  7:28       ` Utkarsh Singh
2022-03-07 22:14         ` Alexander Adolf
     [not found]           ` <87k0d4n8tr.fsf@gmail.com>
     [not found]             ` <c6c39f1b36844a9160e81f2f23cb8458@condition-alpha.com>
2022-03-09  1:06               ` Utkarsh Singh
2022-03-11 17:50                 ` Alexander Adolf
2022-03-13  3:51                   ` Utkarsh Singh
2022-03-15 12:37                     ` Alexander Adolf
2022-03-17  4:56                       ` Utkarsh Singh
2022-03-20 10:49                         ` David Bremner
2022-04-06 12:19                           ` Utkarsh Singh
2022-04-06 18:23                             ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2v8xnn1l3.fsf@guru.guru-group.fi \
    --to=tomi.ollila@iki.fi \
    --cc=notmuch@notmuchmail.org \
    --cc=utkarsh190601@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

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).