From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/48392 Path: main.gmane.org!not-for-mail From: Reiner Steib <4uce.02.r.steib@gmx.net> Newsgroups: gmane.emacs.gnus.general Subject: [Patch] Improvements and additions for gnus-button-alist Date: Mon, 30 Dec 2002 23:05:57 +0100 Sender: owner-ding@hpc.uh.edu Message-ID: Reply-To: reiner.steib@gmx.de NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1041286495 31763 80.91.224.249 (30 Dec 2002 22:14:55 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 30 Dec 2002 22:14:55 +0000 (UTC) Return-path: Original-Received: from util1.math.uh.edu ([129.7.128.22]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18T8BR-0008Fv-00 for ; Mon, 30 Dec 2002 23:14:53 +0100 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by util1.math.uh.edu with esmtp (Exim 4.10) id 18T83B-0003N9-00; Mon, 30 Dec 2002 16:06:21 -0600 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Mon, 30 Dec 2002 16:07:13 -0600 (CST) Original-Received: from theotp5.physik.uni-ulm.de (theotp5.physik.uni-ulm.de [134.60.10.145]) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id QAA14455 for ; Mon, 30 Dec 2002 16:06:55 -0600 (CST) Original-Received: (from ste@localhost) by theotp5.physik.uni-ulm.de (8.11.2/8.11.2) id gBUM5vf16198; Mon, 30 Dec 2002 23:05:57 +0100 X-Authentication-Warning: theotp5.physik.uni-ulm.de: ste set sender to reiner.steib@physik.uni-ulm.de using -f Original-To: ding@hpc.uh.edu X-Face: 3Phac&+dw=IZHjhua]bp}LH<*p{qzj8u+. See also +the variable `gnus-button-handle-ctan'." + :group 'gnus-article-buttons + :link '(custom-manual "(gnus)Group Parameters") + :type '(choice (const "http://www.tex.ac.uk/tex-archive/") + (const "http://tug.ctan.org/tex-archive/") + (const "http://www.dante.de/CTAN/") + (string :tag "Other"))) + +(defcustom gnus-button-ctan-handler 'browse-url + "Function to use for displaying CTAN links. +The function must take one argument, the string naming the URL." + :type '(choice (function-item :tag "Browse Url" browse-url) + (function :tag "Other")) + :group 'gnus-article-buttons) + +(defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/" + "Bogus strings removed from CTAN URLs." + :group 'gnus-article-buttons + :type '(choice (const "^/?tex-archive/\\|/") + (regexp :tag "Other"))) + +(defcustom gnus-button-mid-or-mail-regexp + (concat "\\b\\(\")!;:,{}\n\t ]*@" + gnus-button-valid-fqdn-regexp + ">?\\)\\b") + "Regular expression that matches a message ID or a mail address." + :group 'gnus-article-buttons + :type 'regexp) + (defcustom gnus-button-prefer-mid-or-mail 'guess "What to do when the button on a string as \"foo123@bar.com\" is pushed. Strings like this can be either a message ID or a mail address. If the variable is set to the symbol `ask', query the user what do do. If it is the symbol `guess', Gnus will do a guess and query the user what do do if it is -ambiguous. If it is one of the sybols `mid' or `mail', Gnus will always assume -that the string is a message ID or a mail address, respectivly. See the -variable `gnus-button-guessed-mid-regexp' for details concerning the -guessing." +ambiguous. See the variable `gnus-button-guessed-mid-regexp' for details +concerning the guessing. If it is one of the sybols `mid' or `mail', Gnus +will always assume that the string is a message ID or a mail address, +respectivly." ;; FIXME: doc-string could/should be improved. :group 'gnus-article-buttons :type '(choice (const ask) @@ -5423,10 +5468,35 @@ (if (fboundp 'apropos-variable) 'apropos-variable 'apropos) (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) +(defun gnus-button-handle-apropos-documentation (url) + "Call apropos when pushing the corresponding URL button." + (funcall + (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos) + (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) + +(defun gnus-button-handle-ctan (url) + "Call `browse-url' when pushing a CTAN URL button." + (funcall + gnus-button-ctan-handler + (concat + gnus-ctan-url + (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp "")))) + +(defcustom gnus-button-tex-level 5 + "*Integer that says how many TeX-related buttons Gnus will show. +The higher the number, the more buttons will appear and the more false +positives are possible. Note that you can set this variable local to +specifific groups. Setting it higher in TeX groups is probably a good idea. +See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on +how to set variables in specific groups." + :group 'gnus-article-buttons + :link '(custom-manual "(gnus)Group Parameters") + :type 'integer) + (defcustom gnus-button-man-level 5 "*Integer that says how many man-related buttons Gnus will show. The higher the number, the more buttons will appear and the more false -positves are possible. Note that you can set this variable local to +positives are possible. Note that you can set this variable local to specifific groups. Setting it higher in Unix groups is probably a good idea. See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on how to set variables in specific groups." @@ -5437,9 +5507,9 @@ (defcustom gnus-button-emacs-level 5 "*Integer that says how many emacs-related buttons Gnus will show. The higher the number, the more buttons will appear and the more false -positves are possible. Note that you can set this variable local to +positives are possible. Note that you can set this variable local to specifific groups. Setting it higher in Emacs or Gnus related groups is -probably a good idea.See Info node `(gnus)Group Parameters' and the variable +probably a good idea. See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on how to set variables in specific groups." :group 'gnus-article-buttons :link '(custom-manual "(gnus)Group Parameters") @@ -5448,7 +5518,7 @@ (defcustom gnus-button-mail-level 5 "*Integer that says how many buttons for message IDs or mail addresses will appear. The higher the number, the more buttons will appear and the more false -positves are possible." +positives are possible." :group 'gnus-article-buttons :type 'integer) @@ -5466,6 +5536,9 @@ ("\\( \n\t]+\\)>" 0 t gnus-url-mailto 2) ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1) ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1) + ;; CTAN + ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1) + gnus-button-handle-ctan 1) ;; This is info ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2) @@ -5482,11 +5555,13 @@ 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1) ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1) - ("\\W\\(C-h\\|?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" + ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" + 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1) + ("\\b\\(C-h\\|?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2) - ("\\W\\(C-h\\|?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" + ("\\b\\(C-h\\|?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2) - ("\\W\\(C-h\\|?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0 + ("\\b\\(C-h\\|?\\)[ \t\n]+k[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+" 0 ;; this regexp needs to be fixed! (>= gnus-button-emacs-level 9) gnus-button-handle-describe-key 2) ;; This is how URLs _should_ be embedded in text... @@ -5494,22 +5569,23 @@ ;; Raw URLs. (gnus-button-url-regexp 0 t browse-url 0) ;; man pages - ("\\b\\([a-z][a-z]+\\)([0-9])\\W" 0 + ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3)) gnus-button-handle-man 1) ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x) - ("\\b\\([a-zA-Z][-_.a-zA-Z0-9]+\\)([0-9])\\W" 0 + ("\\b\\([a-zA-Z][-_.a-zA-Z0-9]+\\)([1-9])\\W" 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5)) gnus-button-handle-man 1) - ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), SoWWWAnchor(3iv) - ("\\b\\([a-zA-Z][-_.:a-zA-Z0-9]+\\)([0-9][a-z]*)\\W" 0 + ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), + ;; SoWWWAnchor(3iv), XSelectInput(3X11) + ("\\b\\([a-zA-Z][-_.:a-zA-Z0-9]+\\)([1-9][X1a-z]*)\\W" 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1) ;; MID or mail: To avoid too many false positives we don't try to catch ;; all kind of allowed MIDs or mail addresses. Domain part must contain ;; at least one dot. TLD must contain two or three chars or be a know TLD ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist' ;; so that non-ambiguous entries (see above) match first. - ("\\b\\(\")!;:,{}\n\t ]*@[a-zA-Z0-9][-.a-zA-Z0-9]+\\.\\([a-zA-Z][a-zA-Z]\\([a-zA-Z]\\)?\\|[Ii][Nn][Ff][Oo]\\|[Nn][Aa][Mm][Ee]\\)>?\\)\\b" + (gnus-button-mid-or-mail-regexp 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1)) "*Alist of regexps matching buttons in article bodies. --=-=-= Bye, Reiner. -- ,,, (o o) ---ooO-(_)-Ooo--- PGP key available via WWW http://rsteib.home.pages.de/ --=-=-=--