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

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