~protesilaos/notmuch-indicator

6 2

Extract display logic into customizable function

Details
Message ID
<871qgtazxg.fsf@LPFR0495.mail-host-address-is-not-set>
DKIM signature
pass
Download raw message
Hello Prot,

I hope you are fine.

I wrote this patch because I started to use emacs-minibar package that
allow to use the echo area as a second modeline/statusline.

I thought it was a good idea and a good place for my
notmuch-indicator. But obviously I do not want to display it both in the
modeline and in the echo area.

The idea is move the display logic part in
`notmuch-indicator--indicator` into a separate function called
`notmuch-indicator-display-modeline' that is the default value of a new
customizable variable `notmuch-indicator-display-command`

So the default behavior is still the same, but if users set
`notmuch-indicator-display-command` to nil, it won't display it to the
modeline. But they will still benefit from all the CRON and formatting
logic of this package.

This was the first idea that came to my mind to solve this issue, and
there is may be a better or cleaner way. I have done some basic testing
to check everything was still working fine but feel free to double check
everything.

Also no worries, if you feel like this change is out of scope of this
package.

All the best,

Flo

Re: Extract display logic into customizable function

Details
Message ID
<873518wvpt.fsf@protesilaos.com>
In-Reply-To
<871qgtazxg.fsf@LPFR0495.mail-host-address-is-not-set> (view parent)
DKIM signature
pass
Download raw message
> From: fteissier <teissierflorent@gmail.com>
> Date: Thu, 27 Jul 2023 21:59:23 +0200
>
> Hello Prot,

Hello Flo,

> I hope you are fine.

I am fine, thank you!  I hope the same is true for you.

> I wrote this patch because I started to use emacs-minibar package that
> allow to use the echo area as a second modeline/statusline.
>
> I thought it was a good idea and a good place for my
> notmuch-indicator. But obviously I do not want to display it both in the
> modeline and in the echo area.
>
> The idea is move the display logic part in
> `notmuch-indicator--indicator` into a separate function called
> `notmuch-indicator-display-modeline' that is the default value of a new
> customizable variable `notmuch-indicator-display-command`
>
> So the default behavior is still the same, but if users set
> `notmuch-indicator-display-command` to nil, it won't display it to the
> modeline. But they will still benefit from all the CRON and formatting
> logic of this package.

Yes, this is a good idea.  I don't get how it would be displayed in the
case of a nil value.  It wouldn't, right?

> This was the first idea that came to my mind to solve this issue, and
> there is may be a better or cleaner way. I have done some basic testing
> to check everything was still working fine but feel free to double check
> everything.

Sure, I will give it a try.  Though I am interested to better understand
the customisation options, such that I can document them and know what
to expect in case something doesn't work properly.

> Also no worries, if you feel like this change is out of scope of this
> package.

It is fine.  Thank you!

All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com

Re: Extract display logic into customizable function

Florent Teissier <teissierflorent@gmail.com>
Details
Message ID
<873518fpfr.fsf@LPFR0495.mail-host-address-is-not-set>
In-Reply-To
<873518wvpt.fsf@protesilaos.com> (view parent)
DKIM signature
pass
Download raw message
> I am fine, thank you!  I hope the same is true for you.

I am! thanks :)

> Yes, this is a good idea.  I don't get how it would be displayed in the
> case of a nil value.  It wouldn't, right?

Sure. So it was the first iteration in my config:

(use-package notmuch-indicator
  :straight t
  :init
  ;; don't display in modeline 
  (setq notmuch-indicator-display-command nil)

  ...

  ;; but we still want to run the mode to get notmuch-indicator-string
     populated

  (notmuch-indicator-mode))


(use-package minibar
  ...
  :config
  (setq minibar-group-left '((lambda () notmuch-indicator-string)))
  ...
  (minibar-mode))


But then I realized we could also do something like this

(use-package notmuch-indicator
  :straight t
  :init
  ;; don't display in modeline but in minibar
  (setq notmuch-indicator-display-command (lambda ()
											(setq minibar-group-left '((lambda () notmuch-indicator-string)))))
  (setq notmuch-indicator-args
		'((:terms "tag:unread and tag:inbox" :label "i")
		  (:terms "tag:unread and tag:github" :label "G")
		  (:terms "tag:unread and tag:list" :label "L")))
  (notmuch-indicator-mode))

> Sure, I will give it a try.  Though I am interested to better understand
> the customisation options, such that I can document them and know what
> to expect in case something doesn't work properly.

My very first idea was to just introduce a
`notmuch-indicator-display-modeline-p` boolean customizable variable, as
boolean is always is easier to understand. But I figured that a function
would be the more flexible solution. I'm totally open to another
solution though.

Thanks Prot for your quick answer.

Flo

Re: Extract display logic into customizable function

Details
Message ID
<871qgn2t5p.fsf@protesilaos.com>
In-Reply-To
<873518fpfr.fsf@LPFR0495.mail-host-address-is-not-set> (view parent)
DKIM signature
pass
Download raw message
> From: Florent Teissier <teissierflorent@gmail.com>
> Date: Fri, 28 Jul 2023 09:47:04 +0200

> [... 46 lines elided]

>> Sure, I will give it a try.  Though I am interested to better understand
>> the customisation options, such that I can document them and know what
>> to expect in case something doesn't work properly.
>
> My very first idea was to just introduce a
> `notmuch-indicator-display-modeline-p` boolean customizable variable, as
> boolean is always is easier to understand. But I figured that a function
> would be the more flexible solution. I'm totally open to another
> solution though.

The optional function is more flexible and implies that this is for
advanced users.  Otherwise, we have to assume that someone using the
package agrees to display the indicator.

-- 
Protesilaos Stavrou
https://protesilaos.com

Re: Extract display logic into customizable function

Details
Message ID
<87wmyf1eff.fsf@protesilaos.com>
In-Reply-To
<871qgn2t5p.fsf@protesilaos.com> (view parent)
DKIM signature
pass
Download raw message
> From: Protesilaos Stavrou <info@protesilaos.com>
> Date: Tue,  1 Aug 2023 09:06:26 +0300

> [... 16 lines elided]

> The optional function is more flexible and implies that this is for
> advanced users.  Otherwise, we have to assume that someone using the
> package agrees to display the indicator.

Sorry, I forgot to add this...  Have you assigned copyright to the Free
Software Foundation?  It is needed for all contributions that exceed a
cumulative ~15 line count.  Granted, your patch is rearranging a few
things so I don't know if "15" means "only counting original
contributions", but I must conform with the rules just to be sure.

If you have not assigned copyright to the FSF, I can send you the form.
The whole procedure is done via email and takes about a week.

-- 
Protesilaos Stavrou
https://protesilaos.com

Re: Extract display logic into customizable function

Florent Teissier <teissierflorent@gmail.com>
Details
Message ID
<87pm47ylxw.fsf@LPFR0495.mail-host-address-is-not-set>
In-Reply-To
<87wmyf1eff.fsf@protesilaos.com> (view parent)
DKIM signature
pass
Download raw message
> Sorry, I forgot to add this...  Have you assigned copyright to the Free
> Software Foundation?  It is needed for all contributions that exceed a
> cumulative ~15 line count.  Granted, your patch is rearranging a few
> things so I don't know if "15" means "only counting original
> contributions", but I must conform with the rules just to be sure.

To be honest I'm not familiar at all with this process. On the paper I
don't think I have anything against it, but I'm not sure what it
implies.

> If you have not assigned copyright to the FSF, I can send you the form.
> The whole procedure is done via email and takes about a week.

Yes, I would appreciate if you could send it it to me :)

Re: Extract display logic into customizable function

Details
Message ID
<87r0omgfr9.fsf@protesilaos.com>
In-Reply-To
<87pm47ylxw.fsf@LPFR0495.mail-host-address-is-not-set> (view parent)
DKIM signature
pass
Download raw message
> From: Florent Teissier <teissierflorent@gmail.com>
> Date: Tue,  1 Aug 2023 14:41:15 +0200
>
>> Sorry, I forgot to add this...  Have you assigned copyright to the Free
>> Software Foundation?  It is needed for all contributions that exceed a
>> cumulative ~15 line count.  Granted, your patch is rearranging a few
>> things so I don't know if "15" means "only counting original
>> contributions", but I must conform with the rules just to be sure.
>
> To be honest I'm not familiar at all with this process. On the paper I
> don't think I have anything against it, but I'm not sure what it
> implies.

It allows you to make contributions to Emacs in general.  Though you
will have to consult with the legal department of your job/institution
to be sure you can assign copyright to the FSF.

The reason this is needed for all Emacs contributions is for the FSF to
be able to enforce/defend the GNU General Public License, if needed.

>> If you have not assigned copyright to the FSF, I can send you the form.
>> The whole procedure is done via email and takes about a week.
>
> Yes, I would appreciate if you could send it it to me :)

I copy it below and pre-filled the two first questions for you.  Note
that you do not need to send any of this information to me.

* * *

Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.

Please use your full legal name (in ASCII characters) as the subject
line of the message.

REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES

[What is the name of the program or package you're contributing to?]

GNU Emacs

[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]

Copied a few snippets from the same files I edited.  Their author,
Protesilaos Stavrou, has already assigned copyright to the Free Software
Foundation.

[Do you have an employer who might have a basis to claim to own
your changes?  Do you attend a school which might make such a claim?]


[For the copyright registration, what country are you a citizen of?]


[What year were you born?]


[Please write your email address here.]


[Please write your postal address here.]





[Which files have you changed so far, and which new files have you written
so far?]


-- 
Protesilaos Stavrou
https://protesilaos.com
Reply to thread Export thread (mbox)