From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/55337 Path: main.gmane.org!not-for-mail From: sigurd@12move.de (Karl =?iso-8859-1?q?Pfl=E4sterer?=) Newsgroups: gmane.emacs.gnus.general Subject: Re: A lot of questions concerning `gnus-score-edit-file-at-point' Date: Mon, 29 Dec 2003 20:59:12 +0100 Organization: Lemis World Sender: ding-owner@lists.math.uh.edu Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1072728073 17174 80.91.224.253 (29 Dec 2003 20:01:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 29 Dec 2003 20:01:13 +0000 (UTC) Original-X-From: ding-owner+M3877@lists.math.uh.edu Mon Dec 29 21:01:08 2003 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ab3Zc-000394-00 for ; Mon, 29 Dec 2003 21:01:08 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1Ab3Z5-0001ok-00; Mon, 29 Dec 2003 14:00:35 -0600 Original-Received: from justine.libertine.org ([66.139.78.221] ident=postfix) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1Ab3Yw-0001oc-00 for ding@lists.math.uh.edu; Mon, 29 Dec 2003 14:00:26 -0600 Original-Received: from quimby.gnus.org (quimby.gnus.org [80.91.224.244]) by justine.libertine.org (Postfix) with ESMTP id CB99A3A0047 for ; Mon, 29 Dec 2003 14:00:25 -0600 (CST) Original-Received: from news by quimby.gnus.org with local (Exim 3.35 #1 (Debian)) id 1Ab3Yv-0001zh-00 for ; Mon, 29 Dec 2003 21:00:25 +0100 Original-To: ding@gnus.org Original-Path: wintendo.pflaesterer.de!not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 100 Original-NNTP-Posting-Host: p62.246.56.10.tisdip.tiscali.de Original-X-Trace: quimby.gnus.org 1072728025 7668 62.246.56.10 (29 Dec 2003 20:00:25 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Mon, 29 Dec 2003 20:00:25 +0000 (UTC) X-Face: #iIcL\6>Qj/G*F@AL9T*v/R$j@7Q`6#FU&Flg6u6aVsLdWf(H$U5>:;&*>oy>jOIWgA%8w* A!V7X`\fEGoQ[@D'@i^*p3FCC6&Rg~JT/H_*MOX;"o~flADb8^ Mail-Copies-To: never User-Agent: Gnus/5.1003 (Gnus v5.10.3) Hamster/2.0.4.0 Cancel-Lock: sha1:3MpsGfyIZpGMZg5miELOcGwEOjc= Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:55337 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:55337 On 29 Dec 2003, Reiner Steib <- 4.uce.03.r.s@nurfuerspam.de wrote: > On Sun, Dec 28 2003, Karl Pfl=E4sterer wrote: >> (a) Does anyone really use `gnus-score-edit-file-at-point' outside a >> *Score Trace* buffer? If not the function could be written simpler. > I don't think it's necessary that it works outside *Score Trace* > buffers. So we could use option [d]. That would be the version I prefer also. > Since `ffap' is available in all supported (X)Emacs versions, it's > okay to use it. If we can do the same with `buffer-substring' it's > fine. And perhaps Gnus is 1 millisecond faster and one bit smaller :-) [...] > Unlike the old code, your function always goes to the rule. So we > should change the manual. > ,----[ (info "(gnus)Summary Score Commands") ] > | `V t' > | Display all score rules that have been used on the current article > | (`gnus-score-find-trace'). In the `*Score Trace*' buffer, you can > | use `q' to quit. `e' edits the corresponding score file. When > | point is on a string within the match element, `e' will try to > | bring you to this string in the score file. > `---- Right. The point needn't be on a string. It's enough if you are in the line you are interested in. That raises another question: is the `(setq truncate-lines t)' really necessary? I don't see a reason and I don't like it at all. >> [d]=20 >> (defun gnus-score-edit-file-at-point () > [...] >> (file (save-excursion >> ;; only works in a Score Trace buffer >> (beginning-of-line) >> (re-search-forward "-> +" nil t) > Fails in this example: > ("foo -> bar" 1 nil s) -> /some/score/file Oh right. > Maybe search for a more strict expression, such as ") -> ". I think a re-search-backward is better. =20 > Example: > ("^[^)]+" 2 nil r) -> /some/score/file > Or is there a function to jump to the matching parenthesis, even when > there is one inside the score entry? If not, using `end-of-line' and > `re-search-backward' should be more robust. Yes I think so also (the following solution also groks the non-file rule expression you have if you use eg. bbdb). (defun gnus-score-edit-file-at-point () "Edit score file at point. Useful especially after `V t'." (let ((rule (save-excursion (beginning-of-line) (read (current-buffer)))) (sep "[ \n\r\t]*") (file (save-excursion ;; only works in a Score Trace buffer (end-of-line) (if (and (re-search-backward "-> +" (point-at-bol) t) (re-search-forward "-> +" (point-at-eol) t)) (buffer-substring (point) (point-at-eol)) nil)))) (if (or (string-match "non-file" file) (not file) (string=3D "" file)) (gnus-message 3 "Can't open no file") (gnus-score-edit-file file) (when (consp rule) ;; the rule exists (setq rule (mapconcat #'(lambda (obj) (regexp-quote (format "%S" obj))) rule sep)) (goto-char (point-min)) (re-search-forward rule nil t))))) KP --=20 He took his vorpal sword in hand: Long time the manxome foe he sought-- So rested he by the Tumtum tree, And stood awhile in thought. "Lewis Carroll" "Jabberwocky"