unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [RFC PATCH] emacs: show: make show-get-message-prop usable from pick
@ 2012-12-02 21:29 Mark Walters
  2012-12-02 22:21 ` [PATCH] " Mark Walters
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Walters @ 2012-12-02 21:29 UTC (permalink / raw)
  To: notmuch

Make notmuch-show-get-prop choose the get-message-properties routine
based on the major mode. This make it usable from notmuch-pick and
thus a large number of functions are usable directly from
notmuch-show.el and do not need to be reimplemented in pick.
---

With this change (and a corresponding very small change in pick) I can
use a large number of functions straight from show in pick-mode. The
only change they need is that when they get a message property (most
commonly the message-id) they use the correct routine. This makes the
choice of the routine based on the major-mode.

It seems to work and could save quite a lot of code being essentially
duplicated. Would something like this be acceptable? Would it be way
too slow? Is there some much better way? Any comments (including "Just
don't do that") gratefully received.

Best wishes

Mark



 emacs/notmuch-show.el |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 4d6c014..3e68871 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1378,6 +1378,10 @@ Some useful entries are:
     (notmuch-show-move-to-message-top)
     (get-text-property (point) :notmuch-message-properties)))
 
+(defun notmuch-show-mode-get-message-properties ()
+  "Wrapper for notmuch-show-get-message-properties"
+  (notmuch-show-get-message-properties))
+
 (defun notmuch-show-set-prop (prop val &optional props)
   (let ((inhibit-read-only t)
 	(props (or props
@@ -1387,7 +1391,8 @@ Some useful entries are:
 
 (defun notmuch-show-get-prop (prop &optional props)
   (let ((props (or props
-		   (notmuch-show-get-message-properties))))
+		   (funcall (intern (concat (symbol-name major-mode)
+					    "-get-message-properties"))))))
     (plist-get props prop)))
 
 (defun notmuch-show-get-message-id (&optional bare)
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] emacs: show: make show-get-message-prop usable from pick
  2012-12-02 21:29 [RFC PATCH] emacs: show: make show-get-message-prop usable from pick Mark Walters
@ 2012-12-02 22:21 ` Mark Walters
  2012-12-03  1:22   ` Mark Walters
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Walters @ 2012-12-02 22:21 UTC (permalink / raw)
  To: notmuch

Make notmuch-show-get-prop choose the get-message-properties routine
based on the major mode. This make it usable from notmuch-pick and
thus a large number of functions are usable directly from
notmuch-show.el and do not need to be reimplemented in pick.
---

Ok so the previous version was me being stupid. I was wanting to avoid
errors caused by notmuch-pick-get-message-properties not existing but
the obvious solution is just to define it in a trivial fashion as
here.

Anyway would this be acceptable?

Best wishes

Mark


 emacs/notmuch-show.el |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 4d6c014..b7f64e3 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1378,6 +1378,10 @@ Some useful entries are:
     (notmuch-show-move-to-message-top)
     (get-text-property (point) :notmuch-message-properties)))
 
+(defun notmuch-show-mode-get-message-properties ()
+  "Wrapper for notmuch-show-get-message-properties"
+  (notmuch-show-get-message-properties))
+
 (defun notmuch-show-set-prop (prop val &optional props)
   (let ((inhibit-read-only t)
 	(props (or props
@@ -1385,9 +1389,13 @@ Some useful entries are:
     (plist-put props prop val)
     (notmuch-show-set-message-properties props)))
 
+(defun notmuch-pick-get-message-properties ())
+
 (defun notmuch-show-get-prop (prop &optional props)
   (let ((props (or props
-		   (notmuch-show-get-message-properties))))
+		   (if (eq major-mode 'notmuch-show-mode)
+		       (notmuch-show-get-message-properties)
+		     (notmuch-pick-get-message-properties)))))
     (plist-get props prop)))
 
 (defun notmuch-show-get-message-id (&optional bare)
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] emacs: show: make show-get-message-prop usable from pick
  2012-12-02 22:21 ` [PATCH] " Mark Walters
@ 2012-12-03  1:22   ` Mark Walters
  2012-12-07  8:09     ` Mark Walters
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Walters @ 2012-12-03  1:22 UTC (permalink / raw)
  To: notmuch


Hi

On Sun, 02 Dec 2012, Mark Walters <markwalters1009@gmail.com> wrote:
> Make notmuch-show-get-prop choose the get-message-properties routine
> based on the major mode. This make it usable from notmuch-pick and
> thus a large number of functions are usable directly from
> notmuch-show.el and do not need to be reimplemented in pick.
> ---
>
> Ok so the previous version was me being stupid. I was wanting to avoid
> errors caused by notmuch-pick-get-message-properties not existing but
> the obvious solution is just to define it in a trivial fashion as
> here.

and to continue the stupidity the first hunk is no longer needed: it's
just the second hunk now.

MW

>
> Anyway would this be acceptable?
>
> Best wishes
>
> Mark
>
>
>  emacs/notmuch-show.el |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 4d6c014..b7f64e3 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1378,6 +1378,10 @@ Some useful entries are:
>      (notmuch-show-move-to-message-top)
>      (get-text-property (point) :notmuch-message-properties)))
>  
> +(defun notmuch-show-mode-get-message-properties ()
> +  "Wrapper for notmuch-show-get-message-properties"
> +  (notmuch-show-get-message-properties))
> +
>  (defun notmuch-show-set-prop (prop val &optional props)
>    (let ((inhibit-read-only t)
>  	(props (or props
> @@ -1385,9 +1389,13 @@ Some useful entries are:
>      (plist-put props prop val)
>      (notmuch-show-set-message-properties props)))
>  
> +(defun notmuch-pick-get-message-properties ())
> +
>  (defun notmuch-show-get-prop (prop &optional props)
>    (let ((props (or props
> -		   (notmuch-show-get-message-properties))))
> +		   (if (eq major-mode 'notmuch-show-mode)
> +		       (notmuch-show-get-message-properties)
> +		     (notmuch-pick-get-message-properties)))))
>      (plist-get props prop)))
>  
>  (defun notmuch-show-get-message-id (&optional bare)
> -- 
> 1.7.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] emacs: show: make show-get-message-prop usable from pick
  2012-12-03  1:22   ` Mark Walters
@ 2012-12-07  8:09     ` Mark Walters
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Walters @ 2012-12-07  8:09 UTC (permalink / raw)
  To: notmuch


Just in case anyone is thinking about this: there is a much better
solution. I just redefine notmuch-show-get-prop in notmuch-pick and I
can achieve exactly the same. Hence forget this patch/thread

Many thanks

Mark



Mark Walters <markwalters1009@gmail.com> writes:

> Hi
>
> On Sun, 02 Dec 2012, Mark Walters <markwalters1009@gmail.com> wrote:
>> Make notmuch-show-get-prop choose the get-message-properties routine
>> based on the major mode. This make it usable from notmuch-pick and
>> thus a large number of functions are usable directly from
>> notmuch-show.el and do not need to be reimplemented in pick.
>> ---
>>
>> Ok so the previous version was me being stupid. I was wanting to avoid
>> errors caused by notmuch-pick-get-message-properties not existing but
>> the obvious solution is just to define it in a trivial fashion as
>> here.
>
> and to continue the stupidity the first hunk is no longer needed: it's
> just the second hunk now.
>
> MW
>
>>
>> Anyway would this be acceptable?
>>
>> Best wishes
>>
>> Mark
>>
>>
>>  emacs/notmuch-show.el |   10 +++++++++-
>>  1 files changed, 9 insertions(+), 1 deletions(-)
>>
>> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
>> index 4d6c014..b7f64e3 100644
>> --- a/emacs/notmuch-show.el
>> +++ b/emacs/notmuch-show.el
>> @@ -1378,6 +1378,10 @@ Some useful entries are:
>>      (notmuch-show-move-to-message-top)
>>      (get-text-property (point) :notmuch-message-properties)))
>>  
>> +(defun notmuch-show-mode-get-message-properties ()
>> +  "Wrapper for notmuch-show-get-message-properties"
>> +  (notmuch-show-get-message-properties))
>> +
>>  (defun notmuch-show-set-prop (prop val &optional props)
>>    (let ((inhibit-read-only t)
>>  	(props (or props
>> @@ -1385,9 +1389,13 @@ Some useful entries are:
>>      (plist-put props prop val)
>>      (notmuch-show-set-message-properties props)))
>>  
>> +(defun notmuch-pick-get-message-properties ())
>> +
>>  (defun notmuch-show-get-prop (prop &optional props)
>>    (let ((props (or props
>> -		   (notmuch-show-get-message-properties))))
>> +		   (if (eq major-mode 'notmuch-show-mode)
>> +		       (notmuch-show-get-message-properties)
>> +		     (notmuch-pick-get-message-properties)))))
>>      (plist-get props prop)))
>>  
>>  (defun notmuch-show-get-message-id (&optional bare)
>> -- 
>> 1.7.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-07  8:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-02 21:29 [RFC PATCH] emacs: show: make show-get-message-prop usable from pick Mark Walters
2012-12-02 22:21 ` [PATCH] " Mark Walters
2012-12-03  1:22   ` Mark Walters
2012-12-07  8:09     ` Mark Walters

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