From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/55357 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: Tue, 30 Dec 2003 00:10:52 +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 1072739742 24524 80.91.224.253 (29 Dec 2003 23:15:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 29 Dec 2003 23:15:42 +0000 (UTC) Original-X-From: ding-owner+M3897@lists.math.uh.edu Tue Dec 30 00:15:38 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 1Ab6bq-0005Ah-00 for ; Tue, 30 Dec 2003 00:15:38 +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 1Ab6bk-0003S3-00; Mon, 29 Dec 2003 17:15:32 -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 1Ab6be-0003Ry-00 for ding@lists.math.uh.edu; Mon, 29 Dec 2003 17:15:26 -0600 Original-Received: from quimby.gnus.org (quimby.gnus.org [80.91.224.244]) by justine.libertine.org (Postfix) with ESMTP id 02D163A0047 for ; Mon, 29 Dec 2003 17:15:26 -0600 (CST) Original-Received: from news by quimby.gnus.org with local (Exim 3.35 #1 (Debian)) id 1Ab6bd-0004iY-00 for ; Tue, 30 Dec 2003 00:15:25 +0100 Original-To: ding@gnus.org Original-Path: wintendo.pflaesterer.de!not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 200 Original-NNTP-Posting-Host: p62.246.27.98.tisdip.tiscali.de Original-X-Trace: quimby.gnus.org 1072739725 18137 62.246.27.98 (29 Dec 2003 23:15:25 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Mon, 29 Dec 2003 23:15: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:9iPmLb031VfIrG651Rz9kszNCzE= Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:55357 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:55357 On 29 Dec 2003, Reiner Steib <- 4.uce.03.r.s@nurfuerspam.de wrote: > On Mon, Dec 29 2003, Karl Pfl=E4sterer wrote: >> 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. > Maybe `truncate-lines' has been used because most of the time people > are more interested in the rule than in the file name. I also use > quite often in this buffer to see the filename. Most of the > time I only see the directory. Me too. > But we can make the *Score Trace* buffer more readable with > `truncate-lines': We can use `abbreviate-file-name' on the full file > name and also print the file name (without directory and extension). > It could look like this: > ("@my-fqdn>$" 10000 nil r) [my-posts] -> ~/News/score/topics/my-posts.SC= ORE What are =BB[my-posts]=AB? But `abbreviate-file-name' is a good idea IMO. > Instead of "[", "]" and " -> ", we can use other delimiters: Whatever > fits well in the new `gnus-score-edit-file-at-point' code and is more > or clear for the user. Maybe put these definitions in an alist; use some key and as value a cons cell with the expansion in the score trace buffer and an approbiate regexp. > Additionally, I'd like to add some kind of "Quick help", telling the > user about useful key bindings in that buffer (and maybe explain the > output lines above). See the patch below[1]. Opinions? IMO a good idea. Some annotations to the patch; here we have one of the places where `dolist' is perfectly well suited IMO. The code then becomes[a]=20 If we take the idea of an alist into account we might get[b]=20 But that introduces a new variable; maybe the hint in the commentary is enough. But the alist is nicer of course. And if we wanted it to be perfect we would introduce another variable which holds the name of key. Then only one place had to be changed to get another format. Very easy with customice. > Shouldn't this read... > (if (or (not file) (string-match "non-file" file) (string=3D "" fil= e)) > If file is nil, `string-match' will error out otherwise. Right. I had that first but changed it I don't know why. KP _____ [a]=20 (defun gnus-score-find-trace () "Find all score rules that applies to the current article." (interactive) (let ((old-scored gnus-newsgroup-scored)) (let ((gnus-newsgroup-headers (list (gnus-summary-article-header))) gnus-newsgroup-scored trace file) (save-excursion (nnheader-set-temp-buffer "*Score Trace*")) (setq gnus-score-trace nil) (gnus-possibly-score-headers 'trace) (if (not (setq trace gnus-score-trace)) (gnus-error 1 "No score rules apply to the current article (default score %d)." gnus-summary-default-score) (set-buffer "*Score Trace*") ;; ToDo: Use a keymap instead? (local-set-key "q" (lambda () (interactive) (bury-buffer nil) (gnus-summary-expand-window))) (local-set-key "e" (lambda () "Run `gnus-score-edit-file-at-point'." (interactive) (gnus-score-edit-file-at-point))) (setq truncate-lines t) (dolist (entry trace) (setq file (or (car entry) "(non-file rule)")) (insert (format "%S [%s] -> %s\n" ;; sync with `gnus-score-edit-file-at-point' (cdr entry) (file-name-sans-extension (file-name-nondirectory file)) (abbreviate-file-name file)))) (insert "\n\nQuick help: q - quit e - edit score file entry") (goto-char (point-min)) (gnus-configure-windows 'score-trace))) (set-buffer gnus-summary-buffer) (setq gnus-newsgroup-scored old-scored))) [b]=20 (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]*") (reg (cddr (assq 'newformat gnus-score-trace-format-alist))) (file (save-excursion ;; only works in a Score Trace buffer (end-of-line) (if (and (re-search-backward reg (point-at-bol) t) (re-search-forward reg (point-at-eol) t)) (buffer-substring (point) (point-at-eol)) nil)))) (if (or (not file) (string-match "non-file" 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))))) (defun gnus-score-find-trace () "Find all score rules that applies to the current article." (interactive) (let ((old-scored gnus-newsgroup-scored)) (let ((gnus-newsgroup-headers (list (gnus-summary-article-header))) (frmt (cadr (assq 'newformat gnus-score-trace-format-alist))) gnus-newsgroup-scored trace file) (save-excursion (nnheader-set-temp-buffer "*Score Trace*")) (setq gnus-score-trace nil) (gnus-possibly-score-headers 'trace) (if (not (setq trace gnus-score-trace)) (gnus-error 1 "No score rules apply to the current article (default score %d)." gnus-summary-default-score) (set-buffer "*Score Trace*") ;; ToDo: Use a keymap instead? (local-set-key "q" (lambda () (interactive) (bury-buffer nil) (gnus-summary-expand-window))) (local-set-key "e" (lambda () "Run `gnus-score-edit-file-at-point'." (interactive) (gnus-score-edit-file-at-point))) (setq truncate-lines t) (dolist (entry trace) (setq file (or (car entry) "(non-file rule)")) (insert (format frmt ;; sync with `gnus-score-edit-file-at-point' (cdr entry) (file-name-sans-extension (file-name-nondirectory file)) (abbreviate-file-name file)))) (insert "\n\nQuick help: q - quit e - edit score file entry") (goto-char (point-min)) (gnus-configure-windows 'score-trace))) (set-buffer gnus-summary-buffer) (setq gnus-newsgroup-scored old-scored))) (defvar gnus-score-trace-format-alist (list ;; name format string regexp=20=20=20=20 (cons 'newformat (cons "%S [%s] -> %s\n" "-> +")) (cons 'oldformat (cons "%S -> %3$s\n" "-> +")))) --=20 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe. "Lewis Carroll" "Jabberwocky"