Re: [PATCH] emacs: show: stop display of appliaction/* parts

2017-01-08 Thread Tomas Nordin
Hello Tomi

Tomi Ollila  writes:
> I tried to test the above in emacs *scratch* buffer, but cannot get
> either of the formats work when variable is non-nil.
> example tries
>
> (defcustom a '(a b) "a")
> (defcustom b (list "a" "b") "b")
> (defcustom c (cons 1 nil) "c")
>
> then
>
> (equal a (car (get 'a 'standard-value))) C-j
> nil
>
> (equal (list a) (get 'a 'standard-value)) C-j
> nil
>
> same with b & c
>
> with (defcustom n nil "n") the above work
>
> According to defcustom documentation the expression of STANDARD
> is also stored -- when evaluating (get 'var 'standard-value) the
> output looks like it: for example (get 'c 'standard-value)
> ((cons 1 nil))
>
> If the same happens when using the patch, then we need to look alternative
> -- there might be something good, as customize knows when variable is
> modified...

I played on a bit with your scratch...

(defcustom a '(a b) "a")
(defcustom b (list "a" "b") "b")
(defcustom c (cons 1 nil) "c")
(defcustom T 10 "T")

a -> (a b)
b -> ("a" "b")
c -> (1)
T -> 10

;;; look at one of the plists
(symbol-plist 'a) -> (standard-value ((quote (a b))) custom-requests nil 
variable-documentation "a")

(get 'a 'standard-value) -> ((quote (a b)))
(car (get 'a 'standard-value)) -> (quote (a b))
(eval (car (get 'a 'standard-value))) -> (a b)

(get 'b 'standard-value) -> ((list "a" "b"))
(car (get 'b 'standard-value)) -> (list "a" "b")
(eval (car (get 'b 'standard-value))) -> ("a" "b")

(get 'c 'standard-value) -> ((cons 1 nil))
(car (get 'c 'standard-value)) -> (cons 1 nil)
(eval (car (get 'c 'standard-value))) -> (1)

(get 'T 'standard-value) -> (10)
(car (get 'T 'standard-value)) -> 10
(eval (car (get 'T 'standard-value))) -> 10

(equal a (eval (car (get 'a 'standard-value -> t
(equal b (eval (car (get 'b 'standard-value -> t
(equal c (eval (car (get 'c 'standard-value -> t
(equal T (eval (car (get 'T 'standard-value -> t

Could it be that the car need to be evaled before compared to the value
of the variable? It looks like it with those experiments.

The docs also say something in those lines:

   Internally, ‘defcustom’ uses the symbol property ‘standard-value’ to
record the expression for the standard value, ‘saved-value’ to record
the value saved by the user with the customization buffer, and
‘customized-value’ to record the value set by the user with the
customization buffer, but not saved.  *Note Symbol Properties::.  These
properties are lists, the car of which is an expression that evaluates
to the value.

... thinking about the last sentence. But it seems strange if there is
not a more convenient function to do this.

What do you think?

Best regards
--
Tomas

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: show: stop display of appliaction/* parts

2017-01-08 Thread Tomi Ollila
On Sun, Jan 08 2017, Tomi Ollila  wrote:

> On Sat, Jan 07 2017, Mark Walters  wrote:
>
>> Gnus seems to display application/zip and application/tar by
>> default. This doesn't seem desirable so we override it.
>>
>> We only override ifthe user has not customized
>> mm-inline-override-types themselves.
>> ---
>
> I suggest 2 things:
>
> 1) fix typos ;)
> 2) do it like this: 
> +  (if (equal mm-inline-override-types
> + (car (get 'mm-inline-override-types 'standard-value)))

I tried to test the above in emacs *scratch* buffer, but cannot get
either of the formats work when variable is non-nil.
example tries

(defcustom a '(a b) "a")
(defcustom b (list "a" "b") "b")
(defcustom c (cons 1 nil) "c")

then

(equal a (car (get 'a 'standard-value))) C-j
nil

(equal (list a) (get 'a 'standard-value)) C-j
nil

same with b & c

with (defcustom n nil "n") the above work

According to defcustom documentation the expression of STANDARD
is also stored -- when evaluating (get 'var 'standard-value) the
output looks like it: for example (get 'c 'standard-value)
((cons 1 nil))

If the same happens when using the patch, then we need to look alternative
-- there might be something good, as customize knows when variable is
modified...

Tomi

>
> Tomas: you can also pick the full function definition from notmuch-show.el
> and write it to ~/.emacs.d/notmuch-config.el -- if you do this you
> have to remember to remove it whenever you're upgrading to notmuch 0.24(?)
>
> Tomi
>
>> This was mentioned on irc today and this might be a reasonable way of
>> doing this.
>>
>> It does mean that if a user adds, for example, image/* to
>> mm-inline-override-types then application/* will be displayed again.
>>
>> It also makes it slightly awkward to allow all types (eg setting
>> mm-inline-override-types to non/existent would do).
>>
>> Also I feel there ought to be a better way to tell if a variable has
>> been customized (or otherwise set), but I didn't find one.
>>
>> Best wishes
>>
>> Mark
>>
>>
>> emacs/notmuch-show.el | 10 +-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
>> index 364004b..42734ac 100644
>> --- a/emacs/notmuch-show.el
>> +++ b/emacs/notmuch-show.el
>> @@ -1227,7 +1227,15 @@ matched."
>>(interactive "sNotmuch show: \nP")
>>(let ((buffer-name (generate-new-buffer-name
>>(or buffer-name
>> -  (concat "*notmuch-" thread-id "*")
>> +  (concat "*notmuch-" thread-id "*"
>> +;; We override mm-inline-override-types to stop appliacation/*
>> +;; parts from being displayed unless the user has customized
>> +;; it themselves.
>> +(mm-inline-override-types
>> + (if (equal (list mm-inline-override-types)
>> +(get 'mm-inline-override-types 'standard-value))
>> + (cons "application/*" mm-inline-override-types)
>> +   mm-inline-override-types)))
>>  (switch-to-buffer (get-buffer-create buffer-name))
>>  ;; No need to track undo information for this buffer.
>>  (setq buffer-undo-list t)
>> -- 
>> 2.1.4
>>
>> ___
>> notmuch mailing list
>> notmuch@notmuchmail.org
>> https://notmuchmail.org/mailman/listinfo/notmuch
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: show: stop display of appliaction/* parts

2017-01-08 Thread Tomi Ollila
On Sat, Jan 07 2017, Mark Walters  wrote:

> Gnus seems to display application/zip and application/tar by
> default. This doesn't seem desirable so we override it.
>
> We only override ifthe user has not customized
> mm-inline-override-types themselves.
> ---

I suggest 2 things:

1) fix typos ;)
2) do it like this: 
+(if (equal mm-inline-override-types
+   (car (get 'mm-inline-override-types 'standard-value)))

Tomas: you can also pick the full function definition from notmuch-show.el
and write it to ~/.emacs.d/notmuch-config.el -- if you do this you
have to remember to remove it whenever you're upgrading to notmuch 0.24(?)

Tomi

> This was mentioned on irc today and this might be a reasonable way of
> doing this.
>
> It does mean that if a user adds, for example, image/* to
> mm-inline-override-types then application/* will be displayed again.
>
> It also makes it slightly awkward to allow all types (eg setting
> mm-inline-override-types to non/existent would do).
>
> Also I feel there ought to be a better way to tell if a variable has
> been customized (or otherwise set), but I didn't find one.
>
> Best wishes
>
> Mark
>
>
> emacs/notmuch-show.el | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 364004b..42734ac 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1227,7 +1227,15 @@ matched."
>(interactive "sNotmuch show: \nP")
>(let ((buffer-name (generate-new-buffer-name
> (or buffer-name
> -   (concat "*notmuch-" thread-id "*")
> +   (concat "*notmuch-" thread-id "*"
> + ;; We override mm-inline-override-types to stop appliacation/*
> + ;; parts from being displayed unless the user has customized
> + ;; it themselves.
> + (mm-inline-override-types
> +  (if (equal (list mm-inline-override-types)
> + (get 'mm-inline-override-types 'standard-value))
> +  (cons "application/*" mm-inline-override-types)
> +mm-inline-override-types)))
>  (switch-to-buffer (get-buffer-create buffer-name))
>  ;; No need to track undo information for this buffer.
>  (setq buffer-undo-list t)
> -- 
> 2.1.4
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: show: stop display of appliaction/* parts

2017-01-08 Thread David Bremner
Tomas Nordin  writes:

>
> sudo apt-get remove notmuch
> ... do the source install and re-run notmuch new. It will probably work
> smoothly with the setup I have?

We generally support upgrades but not downgrades. So you can move from
your existing setup to git master, but not necessarily back. You may
also face certain breaking changes in the emacs interface before the
next release.  We try to minimize those, but the nature of emacs means
we can't predict all the ways people have customized their environment.

And of course you're running unreleased software, so you can expect
somewhat less sympathy if things break. That said, most of the
developers run git master happily.
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: show: stop display of appliaction/* parts

2017-01-07 Thread Tomas Nordin
Good evening

> emacs/notmuch-show.el | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 364004b..42734ac 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1227,7 +1227,15 @@ matched."
>(interactive "sNotmuch show: \nP")
>(let ((buffer-name (generate-new-buffer-name
> (or buffer-name
> -   (concat "*notmuch-" thread-id "*")
> +   (concat "*notmuch-" thread-id "*"
> + ;; We override mm-inline-override-types to stop appliacation/*
> + ;; parts from being displayed unless the user has customized
> + ;; it themselves.
> + (mm-inline-override-types
> +  (if (equal (list mm-inline-override-types)
> + (get 'mm-inline-override-types 'standard-value))
> +  (cons "application/*" mm-inline-override-types)
> +mm-inline-override-types)))
>  (switch-to-buffer (get-buffer-create buffer-name))
>  ;; No need to track undo information for this buffer.
>  (setq buffer-undo-list t)
> -- 
> 2.1.4

I applied this to a local copy of notmuch-show.el (notmuch is installed
on debian via apt here) and then eval-defun:ed the function. After that
no inline default display. Seems to work nicely. notmuch version 0.23.1.

By chance it can be easily answered, if I want to use the latest notmuch
installed from source, does it seem like a suitable procedure to do
this;

sudo apt-get remove notmuch
... do the source install and re-run notmuch new. It will probably work
smoothly with the setup I have?
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: show: stop display of appliaction/* parts

2017-01-07 Thread Mark Walters
Gnus seems to display application/zip and application/tar by
default. This doesn't seem desirable so we override it.

We only override ifthe user has not customized
mm-inline-override-types themselves.
---

This was mentioned on irc today and this might be a reasonable way of
doing this.

It does mean that if a user adds, for example, image/* to
mm-inline-override-types then application/* will be displayed again.

It also makes it slightly awkward to allow all types (eg setting
mm-inline-override-types to non/existent would do).

Also I feel there ought to be a better way to tell if a variable has
been customized (or otherwise set), but I didn't find one.

Best wishes

Mark


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

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 364004b..42734ac 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1227,7 +1227,15 @@ matched."
   (interactive "sNotmuch show: \nP")
   (let ((buffer-name (generate-new-buffer-name
  (or buffer-name
- (concat "*notmuch-" thread-id "*")
+ (concat "*notmuch-" thread-id "*"
+   ;; We override mm-inline-override-types to stop appliacation/*
+   ;; parts from being displayed unless the user has customized
+   ;; it themselves.
+   (mm-inline-override-types
+(if (equal (list mm-inline-override-types)
+   (get 'mm-inline-override-types 'standard-value))
+(cons "application/*" mm-inline-override-types)
+  mm-inline-override-types)))
 (switch-to-buffer (get-buffer-create buffer-name))
 ;; No need to track undo information for this buffer.
 (setq buffer-undo-list t)
-- 
2.1.4

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch