Gnus development mailing list
 help / color / mirror / Atom feed
From: sigurd@12move.de (Karl Pflästerer)
Subject: A lot of questions concerning `gnus-score-edit-file-at-point'
Date: Sun, 28 Dec 2003 18:45:31 +0100	[thread overview]
Message-ID: <m34qvkc2g1.fsf@hamster.pflaesterer.de> (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'



             reply	other threads:[~2003-12-28 17:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-28 17:45 Karl Pflästerer [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m34qvkc2g1.fsf@hamster.pflaesterer.de \
    --to=sigurd@12move.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).