Gnus development mailing list
 help / color / mirror / Atom feed
* A lot of questions concerning `gnus-score-edit-file-at-point'
@ 2003-12-28 17:45 Karl Pflästerer
  2003-12-29 17:15 ` Reiner Steib
  0 siblings, 1 reply; 9+ messages in thread
From: Karl Pflästerer @ 2003-12-28 17:45 UTC (permalink / raw)


Hi,
Reiner Steib asked in the NG dcsg if someone liked to look for
`gnus-score-edit-file-at-point' which has a big FIXME in the comment.

So I tried my luck (thought it wouldn't be too hard) and found a working
solution[a].  It's pretty near the original but I'm not really pleased
with it; used in a *Score Trace* buffer it works but fails easily in
another buffer.  So I wrote solution[b].  It works in other buffers also
but it's not the right thing yet IMO.  I have sveral questions

(a) Does anyone really use `gnus-score-edit-file-at-point' outside a
    *Score Trace* buffer?  If not the function could be written simpler.
(b) At the moment `ffap-string-at-point' gets used in that function.
    But that's the sole usage of that function in gnus-score.el (the
    sole usage in Gnus at all).
    If `gnus-score-edit-file-at-point' would only be used in *Score
    Trace* buffers a simple `buffer-substring' would give the same
    effect as `ffap-string-at-point'.
(c) Furthermore there would no longer be a need to define it
    interactive.  To bind it to a key the function could get called by a
    lambda form.  That would help to clean the interactive namespace a
    bit (one function less :-) ).  So that leads to[d]  


So what do you say?


   KP

_____
[a] 
(defun gnus-score-edit-file-at-point ()
  "Edit score file at point.  Useful especially after `V t'."
  (interactive)
  (let ((rule (save-excursion
		(beginning-of-line)
		(read (current-buffer))))
	(sep "[ \n\r\t]*")
	(file (save-excursion
		(end-of-line)
		(ffap-string-at-point))))
    (if (string= "" 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)))))


[b] 
(defun gnus-score-edit-file-at-point ()
  "Edit score file at point.  Useful especially after `V t'."
  (interactive)
  (let ((rule (save-excursion
		(beginning-of-line)
		(read (current-buffer))))
	(sep "[ \n\r\t]*")
	(file (if (string= (buffer-name) "*Score Trace*") 
		;; a Score Trace buffer
		(save-excursion
		  (end-of-line)
		  (ffap-string-at-point))
		(ffap-string-at-point))))
    (if (string= "" 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)))))


[d] 

(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
		(beginning-of-line)
		(re-search-forward "-> +" nil t)
		(buffer-substring (point) (point-at-eol)))))
    (if (string= "" 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 ()
   .
   .
   .
	(local-set-key "e" (lambda ()
			     "Runs `gnus-score-edit-file-at-point'."
			     (interactive)
			     (gnus-score-edit-file-at-point)))

   .
   .)


-- 
Der wahre Weltuntergang ist die Vernichtung des Geistes, der andere hängt von
dem gleichgiltigen Versuch ab, ob nach der Vernichtung des Geistes noch eine
Welt bestehen kann.
                   Karl Kraus 'Untergang der Welt durch schwarze Magie'



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

* Re: A lot of questions concerning `gnus-score-edit-file-at-point'
  2003-12-28 17:45 A lot of questions concerning `gnus-score-edit-file-at-point' Karl Pflästerer
@ 2003-12-29 17:15 ` Reiner Steib
  2003-12-29 19:59   ` Karl Pflästerer
  0 siblings, 1 reply; 9+ messages in thread
From: Reiner Steib @ 2003-12-29 17:15 UTC (permalink / raw)


On Sun, Dec 28 2003, Karl Pflästerer 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].

> (b) At the moment `ffap-string-at-point' gets used in that function.
>     But that's the sole usage of that function in gnus-score.el (the
>     sole usage in Gnus at all).

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.

> (c) Furthermore there would no longer be a need to define it
>     interactive.  To bind it to a key the function could get called by a
>     lambda form.  That would help to clean the interactive namespace a
>     bit (one function less :-) ).  So that leads to[d]  
>
> So what do you say?

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.
`----

> [d] 
>
> (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

Maybe search for a more strict expression, such as ")  ->  ".
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.

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




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

* Re: A lot of questions concerning `gnus-score-edit-file-at-point'
  2003-12-29 17:15 ` Reiner Steib
@ 2003-12-29 19:59   ` Karl Pflästerer
  2003-12-29 21:15     ` Reiner Steib
  0 siblings, 1 reply; 9+ messages in thread
From: Karl Pflästerer @ 2003-12-29 19:59 UTC (permalink / raw)


On 29 Dec 2003, Reiner Steib <- 4.uce.03.r.s@nurfuerspam.de wrote:

> On Sun, Dec 28 2003, Karl Pflästerer 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] 

>> (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.
 
> 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= "" 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

-- 
 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"



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

* Re: A lot of questions concerning `gnus-score-edit-file-at-point'
  2003-12-29 19:59   ` Karl Pflästerer
@ 2003-12-29 21:15     ` Reiner Steib
  2003-12-29 23:10       ` Karl Pflästerer
  0 siblings, 1 reply; 9+ messages in thread
From: Reiner Steib @ 2003-12-29 21:15 UTC (permalink / raw)


On Mon, Dec 29 2003, Karl Pflästerer 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
<end> quite often in this buffer to see the filename.  Most of the
time I only see the directory.

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.SCORE

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.

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?

> (defun gnus-score-edit-file-at-point ()
>   "Edit score file at point.  Useful especially after `V t'."
[...]
>     (if (or (string-match "non-file" file) (not file) (string= "" file))

Shouldn't this read...

      (if (or (not file) (string-match "non-file" file) (string= "" file))

If file is nil, `string-match' will error out otherwise.

Bye, Reiner.


--8<---------------cut here---------------start------------->8---
--- gnus-score.el	22 Dec 2003 11:39:05 -0000	6.38
+++ gnus-score.el	29 Dec 2003 20:54:48 -0000
@@ -2354,7 +2365,8 @@
     (let ((gnus-newsgroup-headers
 	   (list (gnus-summary-article-header)))
 	  (gnus-newsgroup-scored nil)
-	  trace)
+	  trace
+	  file)
       (save-excursion
 	(nnheader-set-temp-buffer "*Score Trace*"))
       (setq gnus-score-trace nil)
@@ -2370,12 +2382,26 @@
 			 (interactive)
 			 (bury-buffer nil)
 			 (gnus-summary-expand-window)))
-	(local-set-key "e" 'gnus-score-edit-file-at-point)
+	(local-set-key "e" (lambda ()
+			     "Run `gnus-score-edit-file-at-point'."
+			     (interactive)
+			     (gnus-score-edit-file-at-point)))
 	(setq truncate-lines t)
 	(while trace
-	  (insert (format "%S  ->  %s\n" (cdar trace)
-			  (or (caar trace) "(non-file rule)")))
+	  (setq file (or (caar trace)
+			 "(non-file rule)"))
+	  (insert (format "%S [%s] -> %s\n"
+			  ;; sync with `gnus-score-edit-file-at-point'
+			  (cdar trace)
+			  (file-name-sans-extension
+			   (file-name-nondirectory file))
+			  (abbreviate-file-name file)))
 	  (setq trace (cdr trace)))
+	(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)
--8<---------------cut here---------------end--------------->8---
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/




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

* Re: A lot of questions concerning `gnus-score-edit-file-at-point'
  2003-12-29 21:15     ` Reiner Steib
@ 2003-12-29 23:10       ` Karl Pflästerer
  2003-12-30 13:40         ` Reiner Steib
  0 siblings, 1 reply; 9+ messages in thread
From: Karl Pflästerer @ 2003-12-29 23:10 UTC (permalink / raw)


On 29 Dec 2003, Reiner Steib <- 4.uce.03.r.s@nurfuerspam.de wrote:

> On Mon, Dec 29 2003, Karl Pflästerer 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
> <end> 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.SCORE

What are »[my-posts]«?

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] 


If we take the idea of an alist into account we might get[b] 
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= "" file))

> 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] 
(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] 
(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= "" 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    
   (cons 'newformat (cons "%S [%s] -> %s\n" "-> +"))
   (cons 'oldformat (cons "%S -> %3$s\n"    "-> +"))))



-- 
'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"



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

* Re: A lot of questions concerning `gnus-score-edit-file-at-point'
  2003-12-29 23:10       ` Karl Pflästerer
@ 2003-12-30 13:40         ` Reiner Steib
  2003-12-30 17:30           ` Karl Pflästerer
  0 siblings, 1 reply; 9+ messages in thread
From: Reiner Steib @ 2003-12-30 13:40 UTC (permalink / raw)


On Tue, Dec 30 2003, Karl Pflästerer wrote:

> On 29 Dec 2003, Reiner Steib <- 4.uce.03.r.s@nurfuerspam.de wrote:
[...]
>> 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.SCORE
>
> What are »[my-posts]«?

"my-posts" is the name of the score file without directory and without
extension:

+			  (file-name-sans-extension
+			   (file-name-nondirectory file))

> [b] 
> (defun gnus-score-edit-file-at-point ()
[...]
> 	 (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))))
[...]
> (defvar gnus-score-trace-format-alist
>   (list ;; name            format string     regexp    
>    (cons 'newformat (cons "%S [%s] -> %s\n" "-> +"))
>    (cons 'oldformat (cons "%S -> %3$s\n"    "-> +"))))

I don't understand the aim behind `gnus-score-trace-format-alist' in
your code.  If 'newformat (or 'oldformat) is hard-coded in the
relevant functions, I see no need for the variable.

We could use a variable to hold the delimiters (and maybe regexps?):

("@my-fqdn>$" 10000 nil r) [my-posts] ->  ~/News/score/topics/my-posts.SCORE
^^^^^^^^^^^^^^^^^^^^^^^^^^--^^^^^^^^_^^^^^----------------------------------
(a)                        |  (c)   | (e)             (f)
                          (b)      (d)

(a) the score rule
(b) opening delimiter for (c)
(c) abbreviated score file name (w/o directory and extension)
(d) closing delimiter for (c)
(e) separator (needed in `gnus-score-edit-file-at-point')
(f) full name of the score file

(b), (d) and (e) could be in the variable (alist).
`gnus-score-edit-file-at-point' and `gnus-score-find-trace' use this
variable.

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




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

* Re: A lot of questions concerning `gnus-score-edit-file-at-point'
  2003-12-30 13:40         ` Reiner Steib
@ 2003-12-30 17:30           ` Karl Pflästerer
  2003-12-30 20:58             ` Reiner Steib
  0 siblings, 1 reply; 9+ messages in thread
From: Karl Pflästerer @ 2003-12-30 17:30 UTC (permalink / raw)


On 30 Dec 2003, Reiner Steib <- 4.uce.03.r.s@nurfuerspam.de wrote:

> On Tue, Dec 30 2003, Karl Pflästerer wrote:

>> (defvar gnus-score-trace-format-alist
>>   (list ;; name            format string     regexp    
>>    (cons 'newformat (cons "%S [%s] -> %s\n" "-> +"))
>>    (cons 'oldformat (cons "%S -> %3$s\n"    "-> +"))))

> I don't understand the aim behind `gnus-score-trace-format-alist' in
> your code.  If 'newformat (or 'oldformat) is hard-coded in the
> relevant functions, I see no need for the variable.

If you use that var you asure that the two functions use the right pair
of format string and regexp.

As I wrote: best would be to have a second var which holds the name of
the key.

> We could use a variable to hold the delimiters (and maybe regexps?):

I don't see the difference to what I wrote.

> ("@my-fqdn>$" 10000 nil r) [my-posts] ->  ~/News/score/topics/my-posts.SCORE
> ^^^^^^^^^^^^^^^^^^^^^^^^^^--^^^^^^^^_^^^^^----------------------------------
> (a)                        |  (c)   | (e)             (f)
>                           (b)      (d)

> (a) the score rule
> (b) opening delimiter for (c)
> (c) abbreviated score file name (w/o directory and extension)
> (d) closing delimiter for (c)
> (e) separator (needed in `gnus-score-edit-file-at-point')
> (f) full name of the score file

> (b), (d) and (e) could be in the variable (alist).
> `gnus-score-edit-file-at-point' and `gnus-score-find-trace' use this
> variable.

The same as I proposed.  But with my proposal it's easy to add and use
new formats.

You would have two new vars:
`gnus-score-trace-format-alist' and `gnus-score-trace-format'.  The
later one has eg. 'oldformat as value.  Everywhere you see at the moment
oldformat that var could be used.  With that you are free to create
fancy formats.  Only the rule must be first and the long file name last
on the line.




   KP

-- 
"Programs must be written for people to read, and only incidentally
for machines to execute."
                -- Abelson & Sussman, SICP (preface to the first edition)



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

* Re: A lot of questions concerning `gnus-score-edit-file-at-point'
  2003-12-30 17:30           ` Karl Pflästerer
@ 2003-12-30 20:58             ` Reiner Steib
  2003-12-30 21:17               ` Karl Pflästerer
  0 siblings, 1 reply; 9+ messages in thread
From: Reiner Steib @ 2003-12-30 20:58 UTC (permalink / raw)


On Tue, Dec 30 2003, Karl Pflästerer wrote:

> On 30 Dec 2003, Reiner Steib <- 4.uce.03.r.s@nurfuerspam.de wrote:
[...]
> As I wrote: best would be to have a second var which holds the name of
> the key.
>
>> We could use a variable to hold the delimiters (and maybe regexps?):
>
> I don't see the difference to what I wrote.

This is because I didn't understand your proposal. ;-)

> You would have two new vars:
> `gnus-score-trace-format-alist' and `gnus-score-trace-format'.  The
> later one has eg. 'oldformat as value.  Everywhere you see at the moment
> oldformat that var could be used.  With that you are free to create
> fancy formats.

Wouldn't it make more sense to defcustom
`gnus-score-trace-format-alist' and offer some predefined choices:

  :type '(choice (const :tag "old style" ...)
		 (const :tag "news style" ...)
		 (const :tag "foo style" ...))

I have committed new versions of `gnus-score-edit-file-at-point' and
`gnus-score-find-trace' now.  `gnus-score-edit-file-at-point' is your
latest version but without `gnus-score-trace-format-alist' (we may add
this later) and some minor modifications.  `gnus-score-find-trace'
uses `dolist' as you suggested.  I hope it's okay for you.

(You have signed copyright assignments, IIRC?)

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




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

* Re: A lot of questions concerning `gnus-score-edit-file-at-point'
  2003-12-30 20:58             ` Reiner Steib
@ 2003-12-30 21:17               ` Karl Pflästerer
  0 siblings, 0 replies; 9+ messages in thread
From: Karl Pflästerer @ 2003-12-30 21:17 UTC (permalink / raw)


On 30 Dec 2003, Reiner Steib <- 4.uce.03.r.s@nurfuerspam.de wrote:

> Wouldn't it make more sense to defcustom
> `gnus-score-trace-format-alist' and offer some predefined choices:

>   :type '(choice (const :tag "old style" ...)
> 		 (const :tag "news style" ...)
> 		 (const :tag "foo style" ...))

Sure.  I think I wrote that also :-)  If we use it it makes sense to
write a defcustom; for testing defvar is simpler.

> I have committed new versions of `gnus-score-edit-file-at-point' and
> `gnus-score-find-trace' now.  `gnus-score-edit-file-at-point' is your
> latest version but without `gnus-score-trace-format-alist' (we may add
> this later) and some minor modifications.  `gnus-score-find-trace'
> uses `dolist' as you suggested.  I hope it's okay for you.

I'll do a checkout and look at it.  If you said you wanted to commit I
could have written something for the Changelog.

> (You have signed copyright assignments, IIRC?)

Right.


   KP

-- 
Roses are red,
  Violets are blue,
I'm schizophrenic...
  And I am too.



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

end of thread, other threads:[~2003-12-30 21:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-28 17:45 A lot of questions concerning `gnus-score-edit-file-at-point' Karl Pflästerer
2003-12-29 17:15 ` Reiner Steib
2003-12-29 19:59   ` Karl Pflästerer
2003-12-29 21:15     ` Reiner Steib
2003-12-29 23:10       ` Karl Pflästerer
2003-12-30 13:40         ` Reiner Steib
2003-12-30 17:30           ` Karl Pflästerer
2003-12-30 20:58             ` Reiner Steib
2003-12-30 21:17               ` Karl Pflästerer

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).