Gnus development mailing list
 help / color / mirror / Atom feed
* Buttons for M-x customize-*
@ 2005-12-12 18:55 Ralf Angeli
  2005-12-12 22:30 ` Reiner Steib
  0 siblings, 1 reply; 7+ messages in thread
From: Ralf Angeli @ 2005-12-12 18:55 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 785 bytes --]

Following up on a discussion in de.comm.software.gnus I'd like to
propose a change in the handling of `M-x customize-*' buttons.
Currently `customize-apropos' is called on any such string.  This may
result in a little bit unexpected behavior.  Check for example the
result of `M-x customize-face RET highlight RET'.

In my opinion it would be better if the given function were called
exactly instead of `customize-apropos'.  The attached patch
accomplishes this.  The patch also removes support for "custom:" and
"custom:/" type urls which I've never seen before.  Of course this is
discussable.  Keeping it included would either require two separate
functions for handling the customize stuff or a conditionalization
inside of `gnus-button-handle-custom'.  WDYT?

Here is the patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1295 bytes --]

--- gnus-art.el	26 Nov 2005 15:11:37 +0100	7.132
+++ gnus-art.el	12 Dec 2005 19:37:07 +0100	
@@ -6295,9 +6295,10 @@
 	   (gnus-url-mailto url-mailto))
 	  (t (gnus-message 3 "Invalid string.")))))
 
-(defun gnus-button-handle-custom (url)
-  "Follow a Custom URL."
-  (customize-apropos (gnus-url-unhex-string url)))
+(defun gnus-button-handle-custom (fun symbol)
+  "Call function FUN on SYMBOL.
+Both FUN and SYMBOL are supposed to be strings."
+  (funcall (intern fun) (intern symbol)))
 
 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
 
@@ -6477,10 +6478,8 @@
      ;; Info links like `C-h i d m CC Mode RET'
      0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
     ;; This is custom
-    ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
-     0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
-    ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
-     (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
+    ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
+     (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
     ;; Emacs help commands
     ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
      ;; regexp doesn't match arguments containing ` '.

[-- Attachment #3: Type: text/plain, Size: 93 bytes --]


(I'll provide a ChangeLog entry once it is settled what exactly to do
with this.)

-- 
Ralf

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

* Re: Buttons for M-x customize-*
  2005-12-12 18:55 Buttons for M-x customize-* Ralf Angeli
@ 2005-12-12 22:30 ` Reiner Steib
  2005-12-13  9:05   ` Ralf Angeli
  2005-12-13 16:39   ` Simon Josefsson
  0 siblings, 2 replies; 7+ messages in thread
From: Reiner Steib @ 2005-12-12 22:30 UTC (permalink / raw)


On Mon, Dec 12 2005, Ralf Angeli wrote:

> [...]  Check for example the result of `M-x customize-face RET
> highlight RET'.
>
> In my opinion it would be better if the given function were called
> exactly instead of `customize-apropos'.  The attached patch
> accomplishes this.  The patch also removes support for "custom:" and
> "custom:/" type urls which I've never seen before.

According to the ChangeLog, I've added the support for "custom:/?"
because it we previously suggested by Simon:
<http://mid.gmane.org/iluheuqpqpa.fsf%40barbar.josefsson.org>
<http://thread.gmane.org/v9it13c9od.fsf%40marauder.physik.uni-ulm.de>
But I don't recall that I ever saw "custom:" URLs in the wild; Simon
did you?

Unless there are other suggestions, I'll install Ralf's patch.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

* Re: Buttons for M-x customize-*
  2005-12-12 22:30 ` Reiner Steib
@ 2005-12-13  9:05   ` Ralf Angeli
  2005-12-13 16:39   ` Simon Josefsson
  1 sibling, 0 replies; 7+ messages in thread
From: Ralf Angeli @ 2005-12-13  9:05 UTC (permalink / raw)


* Reiner Steib (2005-12-12) writes:

> Unless there are other suggestions, I'll install Ralf's patch.

One additional thought: The function `gnus-button-handle-custom' in
the patch is so generic now that it could probably be called something
like `gnus-button-funcall-on-strings'.  If it should be named like
that, I'll change its interface so that it can accept an arbitrary
number of arguments just like `funcall'.

-- 
Ralf




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

* Re: Buttons for M-x customize-*
  2005-12-12 22:30 ` Reiner Steib
  2005-12-13  9:05   ` Ralf Angeli
@ 2005-12-13 16:39   ` Simon Josefsson
  2005-12-14 11:25     ` Ralf Angeli
  1 sibling, 1 reply; 7+ messages in thread
From: Simon Josefsson @ 2005-12-13 16:39 UTC (permalink / raw)


Reiner Steib <reinersteib+gmane@imap.cc> writes:

> On Mon, Dec 12 2005, Ralf Angeli wrote:
>
>> [...]  Check for example the result of `M-x customize-face RET
>> highlight RET'.
>>
>> In my opinion it would be better if the given function were called
>> exactly instead of `customize-apropos'.  The attached patch
>> accomplishes this.  The patch also removes support for "custom:" and
>> "custom:/" type urls which I've never seen before.
>
> According to the ChangeLog, I've added the support for "custom:/?"
> because it we previously suggested by Simon:
> <http://mid.gmane.org/iluheuqpqpa.fsf%40barbar.josefsson.org>
> <http://thread.gmane.org/v9it13c9od.fsf%40marauder.physik.uni-ulm.de>
> But I don't recall that I ever saw "custom:" URLs in the wild; Simon
> did you?

No.  Since it is not registered, we should either register it or
remove it.  I'm not sure custom: URLs are that useful, so removing it
is probably fine.

Ralf Angeli <angeli@iwi.uni-sb.de> writes:

> * Reiner Steib (2005-12-12) writes:
>
>> Unless there are other suggestions, I'll install Ralf's patch.
>
> One additional thought: The function `gnus-button-handle-custom' in
> the patch is so generic now that it could probably be called something
> like `gnus-button-funcall-on-strings'.  If it should be named like
> that, I'll change its interface so that it can accept an arbitrary
> number of arguments just like `funcall'.

I think this would be better.



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

* Re: Buttons for M-x customize-*
  2005-12-13 16:39   ` Simon Josefsson
@ 2005-12-14 11:25     ` Ralf Angeli
  2005-12-14 13:17       ` Reiner Steib
  0 siblings, 1 reply; 7+ messages in thread
From: Ralf Angeli @ 2005-12-14 11:25 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1660 bytes --]

* Simon Josefsson (2005-12-13) writes:

> No.  Since it is not registered, we should either register it or
> remove it.  I'm not sure custom: URLs are that useful, so removing it
> is probably fine.

Okay, this is still being done in the updated patch attached to this
message.

> Ralf Angeli <angeli@iwi.uni-sb.de> writes:
>
>> One additional thought: The function `gnus-button-handle-custom' in
>> the patch is so generic now that it could probably be called something
>> like `gnus-button-funcall-on-strings'.  If it should be named like
>> that, I'll change its interface so that it can accept an arbitrary
>> number of arguments just like `funcall'.
>
> I think this would be better.

I thought about this once more and I don't think it can be generalized
so easily.  The customize-* functions expect symbols as arguments, so
the strings coming from the regexps used for parsing an article have
to be interned.  So I'd have to intern every argument passed to a
hypothetical `gnus-button-funcall-on-strings'.  But of course not
every possible function to be called through it expects symbols as
arguments.  So for now I left the function name alone in order to
document its limited usefuleness.

Here is a ChangeLog entry and the patch:

2005-12-14  Ralf Angeli  <angeli@iwi.uni-sb.de>

	* gnus-art.el (gnus-button-handle-custom): Do not just use
	`customize-apropos' for any "M-x customize-*" button but the
	function called for.  Accept both the function name and its
	argument in order to achieve this.
	(gnus-button-alist): Remove support for "custom:" URL's.  Pass
	function name to `gnus-button-handle-custom' in case of "M-x
	customize-*" buttons.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1529 bytes --]

Index: gnus-art.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/gnus-art.el,v
retrieving revision 7.133
diff -u -r7.133 gnus-art.el
--- gnus-art.el	12 Dec 2005 23:06:59 -0000	7.133
+++ gnus-art.el	14 Dec 2005 11:24:00 -0000
@@ -6297,9 +6297,11 @@
 	   (gnus-url-mailto url-mailto))
 	  (t (gnus-message 3 "Invalid string.")))))
 
-(defun gnus-button-handle-custom (url)
-  "Follow a Custom URL."
-  (customize-apropos (gnus-url-unhex-string url)))
+(defun gnus-button-handle-custom (fun arg)
+  "Call function FUN on argument ARG.
+Both FUN and ARG are supposed to be strings.  ARG will be passed
+as a symbol to FUN."
+  (funcall (intern fun) (intern symbol)))
 
 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
 
@@ -6479,10 +6481,8 @@
      ;; Info links like `C-h i d m CC Mode RET'
      0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
     ;; This is custom
-    ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
-     0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
-    ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
-     (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
+    ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
+     (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
     ;; Emacs help commands
     ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
      ;; regexp doesn't match arguments containing ` '.

[-- Attachment #3: Type: text/plain, Size: 10 bytes --]


-- 
Ralf

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

* Re: Buttons for M-x customize-*
  2005-12-14 11:25     ` Ralf Angeli
@ 2005-12-14 13:17       ` Reiner Steib
  2005-12-14 13:37         ` Ralf Angeli
  0 siblings, 1 reply; 7+ messages in thread
From: Reiner Steib @ 2005-12-14 13:17 UTC (permalink / raw)


On Wed, Dec 14 2005, Ralf Angeli wrote:

> 2005-12-14  Ralf Angeli  <angeli@iwi.uni-sb.de>
>
> 	* gnus-art.el (gnus-button-handle-custom): Do not just use
> 	`customize-apropos' for any "M-x customize-*" button but the
> 	function called for.  Accept both the function name and its
> 	argument in order to achieve this.
> 	(gnus-button-alist): Remove support for "custom:" URL's.  Pass
> 	function name to `gnus-button-handle-custom' in case of "M-x
> 	customize-*" buttons.
[...]
> +(defun gnus-button-handle-custom (fun arg)
> +  "Call function FUN on argument ARG.
> +Both FUN and ARG are supposed to be strings.  ARG will be passed
> +as a symbol to FUN."
> +  (funcall (intern fun) (intern symbol)))
                                   ^^^^^^ You meant "arg" here, I think.


Applied.  Thanks.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

* Re: Buttons for M-x customize-*
  2005-12-14 13:17       ` Reiner Steib
@ 2005-12-14 13:37         ` Ralf Angeli
  0 siblings, 0 replies; 7+ messages in thread
From: Ralf Angeli @ 2005-12-14 13:37 UTC (permalink / raw)


* Reiner Steib (2005-12-14) writes:

> On Wed, Dec 14 2005, Ralf Angeli wrote:
>
>> +(defun gnus-button-handle-custom (fun arg)
>> +  "Call function FUN on argument ARG.
>> +Both FUN and ARG are supposed to be strings.  ARG will be passed
>> +as a symbol to FUN."
>> +  (funcall (intern fun) (intern symbol)))
>                                    ^^^^^^ You meant "arg" here, I think.

Uh, yes.  Damn notestingrequiredcleanupchanges. (c:

-- 
Ralf




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

end of thread, other threads:[~2005-12-14 13:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-12 18:55 Buttons for M-x customize-* Ralf Angeli
2005-12-12 22:30 ` Reiner Steib
2005-12-13  9:05   ` Ralf Angeli
2005-12-13 16:39   ` Simon Josefsson
2005-12-14 11:25     ` Ralf Angeli
2005-12-14 13:17       ` Reiner Steib
2005-12-14 13:37         ` Ralf Angeli

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 NNTP newsgroup(s).