* Mechaincal question Show filename of # marked @ 2000-12-21 3:06 Harry Putnam 2000-12-21 10:02 ` Kai Großjohann 2000-12-21 15:42 ` Kai Großjohann 0 siblings, 2 replies; 10+ messages in thread From: Harry Putnam @ 2000-12-21 3:06 UTC (permalink / raw) Is there some quick easy way of extracting the filenames of messages that are process marked? Gnus is able to limit the view to or do other things to a group of messages earmarked with "#", so it must have some record of which filenames are currently wearing that mark. How can I extract that information or export it? I want a current list of the file names of messages marked with "#" in a summary buffer. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Mechaincal question Show filename of # marked 2000-12-21 3:06 Mechaincal question Show filename of # marked Harry Putnam @ 2000-12-21 10:02 ` Kai Großjohann 2000-12-21 14:28 ` Harry Putnam 2000-12-21 15:42 ` Kai Großjohann 1 sibling, 1 reply; 10+ messages in thread From: Kai Großjohann @ 2000-12-21 10:02 UTC (permalink / raw) Cc: ding On 20 Dec 2000, Harry Putnam wrote: > Is there some quick easy way of extracting the filenames of messages > that are process marked? The variable gnus-newsgroup-processable contains a list of article numbers. The variable gnus-newsgroup-name contains the group name. With (mapcar (lambda (g) (expand-file-name g (gnus-group-real-name gnus-newsgroup-name "~/Mail/"))) gnus-newsgroup-processable) you should be able to get a list of file names. But this only works for nnml and nnmh groups. This code is not tested. Does it work? kai -- ~/.signature ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Mechaincal question Show filename of # marked 2000-12-21 10:02 ` Kai Großjohann @ 2000-12-21 14:28 ` Harry Putnam 0 siblings, 0 replies; 10+ messages in thread From: Harry Putnam @ 2000-12-21 14:28 UTC (permalink / raw) Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes: > On 20 Dec 2000, Harry Putnam wrote: > > > Is there some quick easy way of extracting the filenames of messages > > that are process marked? > > The variable gnus-newsgroup-processable contains a list of article > numbers. The variable gnus-newsgroup-name contains the group name. > > With > > (mapcar (lambda (g) > (expand-file-name g (gnus-group-real-name gnus-newsgroup-name > "~/Mail/"))) > gnus-newsgroup-processable) > > you should be able to get a list of file names. But this only works > for nnml and nnmh groups. This code is not tested. Does it work? The variables do in fact hold the information I want. So theres a big jump up... Now since I'm a no-lisp reading moron.. I'm not sure what your code is supposed to do. Or what I should do with it. I assumed it was intended to be evaluated... So with the variables giving this information: gnus-newsgroup-name's value is "nnml:ding3" <== the ding@gnus.org list -o- gnus-newsgroup-processable's value is (17 53 22 16 8 7) Local in buffer *Summary nnml:ding3*; global value is nil Evaling your code gives me: M-: (mapcar (lambda (g) (expand-file-name g (gnus-group-real-name gnus-newsgroup-name "~/Mail/"))) gnus-newsgroup-processable) <RET> nil ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Mechaincal question Show filename of # marked 2000-12-21 3:06 Mechaincal question Show filename of # marked Harry Putnam 2000-12-21 10:02 ` Kai Großjohann @ 2000-12-21 15:42 ` Kai Großjohann 2000-12-21 15:55 ` Harry Putnam 1 sibling, 1 reply; 10+ messages in thread From: Kai Großjohann @ 2000-12-21 15:42 UTC (permalink / raw) Cc: ding Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes: > (mapcar (lambda (g) > (expand-file-name g (gnus-group-real-name > gnus-newsgroup-name > "~/Mail/"))) > gnus-newsgroup-processable) I forgot a number of function calls. In particular, gnus-group-real-name only takes 1 argument, the group name. (It converts "nnml:foo.bar" into "foo.bar".) Then I need to call nnheader-group-pathname to convert the group name into a directory name. (It converts "foo.bar" into "~/Mail/foo/bar/".) And I was forgetting to convert the article number (from gnus-newsgroup-processable) into a string -- hence int-to-string. (mapcar (lambda (g) (expand-file-name (int-to-string g) (nnheader-group-pathname (gnus-group-real-name gnus-newsgroup-name) "~/Mail/"))) gnus-newsgroup-processable) Does this work? Eval with `:'. Put it into a function call if you like. What do you want to do with it? kai -- ~/.signature ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Mechaincal question Show filename of # marked 2000-12-21 15:42 ` Kai Großjohann @ 2000-12-21 15:55 ` Harry Putnam 2000-12-22 3:15 ` Colin Walters 2000-12-22 8:40 ` Kai Großjohann 0 siblings, 2 replies; 10+ messages in thread From: Harry Putnam @ 2000-12-21 15:55 UTC (permalink / raw) Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes: > Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes: > > > (mapcar (lambda (g) > > (expand-file-name g (gnus-group-real-name > > gnus-newsgroup-name > > "~/Mail/"))) > > gnus-newsgroup-processable) > > I forgot a number of function calls. In particular, > gnus-group-real-name only takes 1 argument, the group name. (It > converts "nnml:foo.bar" into "foo.bar".) > > Then I need to call nnheader-group-pathname to convert the group name > into a directory name. (It converts "foo.bar" into > "~/Mail/foo/bar/".) > > And I was forgetting to convert the article number (from > gnus-newsgroup-processable) into a string -- hence int-to-string. > > (mapcar (lambda (g) > (expand-file-name (int-to-string g) > (nnheader-group-pathname > (gnus-group-real-name gnus-newsgroup-name) > "~/Mail/"))) > gnus-newsgroup-processable) > > Does this work? Eval with `:'. Put it into a function call if you > like. What do you want to do with it? Yes... It gives a nice list like this: ("/home/reader/Mail/prinb/13456" "/home/reader/Mail/prinb/13455" \ "/home/reader/Mail/prinb/13454" "/home/reader/Mail/prinb/13453") Cool. How can I feed that list to a shell script? Can I pipe it to a shell script some how? > . . . What do you want to do with it? That list will become stdin to some scripting (shell/awk) that will compare the message-id of those messages to message-id's already in $TARGET group. So that before continuing my process (which is either move `B m' or copy `B c') I can learn whether any of the process marked messages are already in $TARGET What to do then, I haven't got figured out yet. Maybe just make the move outside gnus and let `M-x nnml-generate bla' clean it up later. I've been thinking about doing all kinds of crufty stuff behind gnus back since it has that handy clean up tool. A cron job at night to make things right. (poetry eh?) I move stuff around a fair bit so I run into a problem very often where I'm not sure if something has already been copied to a specific group. I've managed to piece together shell/awk scripts that do a fine job of comparing Message-IDs and reporting which files are unique etc. But the whole thing depends on getting that processs information which I now have. (... thanks) .. Just need to pipeline it into my scripting and see if there is some way to hand gnus back a list to move copy or whatever. If that seems to hard then just do it outside gnus. Probably clever ways to hook this shell scripting into something that gets called when `B m' is called. How does one call a shell script from within lisp? Here is one, probably fool idea.. A `for' loop in lisp that runs through that list and records the Message-ids, and compares them to a cache held somewhere. Determines if any are dups and tells the user if so. queries user whether or not to proceed. Process marks are adjusted to suit the findings internally somehow. and then..... Chocolate cake and ice cream is served. Gnus does the dishes. .... In the .. he he he...`kitchen sink (TM)' ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Mechaincal question Show filename of # marked 2000-12-21 15:55 ` Harry Putnam @ 2000-12-22 3:15 ` Colin Walters 2000-12-22 5:10 ` Harry Putnam 2000-12-22 8:40 ` Kai Großjohann 1 sibling, 1 reply; 10+ messages in thread From: Colin Walters @ 2000-12-22 3:15 UTC (permalink / raw) Harry Putnam <reader@newsguy.com> writes: > Yes... It gives a nice list like this: > > ("/home/reader/Mail/prinb/13456" "/home/reader/Mail/prinb/13455" \ > "/home/reader/Mail/prinb/13454" "/home/reader/Mail/prinb/13453") > > Cool. > > How can I feed that list to a shell script? Can I pipe it to a > shell script some how? There are a few list processing functions you can use. In Emacs 20, the traditional way to do this is with `mapcar', and an anonymous function (lambda). So for example, if you want to run a shell command foo on those files: (mapcar (lambda (x) (shell-command-to-string (concat "foo " x))) thelist) where `thelist' is a variable in which you have stored the above list. If you use the CL macro `dolist', you can say: (require 'cl) (dolist (x thelist) (shell-command-to-string (concat "foo " x))) There are some differences between the above two forms, but those differences aren't really important for this task. `dolist' will be builtin to Emacs 21, too. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Mechaincal question Show filename of # marked 2000-12-22 3:15 ` Colin Walters @ 2000-12-22 5:10 ` Harry Putnam 2000-12-22 6:05 ` Colin Walters 2000-12-22 8:44 ` Kai Großjohann 0 siblings, 2 replies; 10+ messages in thread From: Harry Putnam @ 2000-12-22 5:10 UTC (permalink / raw) Colin Walters <walters@cis.ohio-state.edu> writes: > Harry Putnam <reader@newsguy.com> writes: > > > Yes... It gives a nice list like this: > > > > ("/home/reader/Mail/prinb/13456" "/home/reader/Mail/prinb/13455" \ > > "/home/reader/Mail/prinb/13454" "/home/reader/Mail/prinb/13453") > > > > Cool. > > > > How can I feed that list to a shell script? Can I pipe it to a > > shell script some how? > > There are a few list processing functions you can use. In Emacs 20, > the traditional way to do this is with `mapcar', and an anonymous > function (lambda). > OK trying to get in to this, but I have no clue how that list might be stored into a variable... In the shell, no problem but in lisp.. I'm lost. Imagine for a minute that you are talking to one of the inmates in `One Flew Over the Cuckoos Nest': Taking the first example, since I don't know how to generate a variable containing a list I try using a single file name instead, and insert something simple for a shell command `cat' (UUofC not withstanding) I'm guessing this is like a simple `for loop' and cat will be run on each member in turn. So with just 1 member then maybe just on it. (mapcar (lambda (x) (shell-command-to-string (concat "cat " x))) /home/reader/Mail/tmp/awk-work/13) So C-x C-e Symbol's value as variable is void: \ /home/reader/Mail/tmp/awk-work/13 OK, I'm guessing it wants more paren or double quotes or something (mapcar (lambda (x) (shell-command-to-string (concat "cat " x))) "/home/reader/Mail/tmp/awk-work/13") C-x C-e ("cat: 47: No such file or directory " "cat: 104: No such file or directory " "cat: 111: No such file or directory [...] snip about 20 more lines Well, I'm getting closer... May sound terribly lame, but I don't even have a clue on how to begin looking this up in the Into or Lisp manual. Good thing this isn't explosive... I'd have had a serious accident by now. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Mechaincal question Show filename of # marked 2000-12-22 5:10 ` Harry Putnam @ 2000-12-22 6:05 ` Colin Walters 2000-12-22 8:44 ` Kai Großjohann 1 sibling, 0 replies; 10+ messages in thread From: Colin Walters @ 2000-12-22 6:05 UTC (permalink / raw) Harry Putnam <reader@newsguy.com> writes: > OK trying to get in to this, but I have no clue how that list might > be stored into a variable... In the shell, no problem but in > lisp.. I'm lost. Ok. By the way, I highly recommend Robert Chassell's "Programming in Emacs Lisp: An Introduction". It's how I started to learn Emacs Lisp. > Taking the first example, since I don't know how to generate a > variable containing a list I try using a single file name instead, > and insert something simple for a shell command `cat' (UUofC not > withstanding) Well, one way to (implicitly) create variables is with `setq', which you've probably seen before. Say you type (setq foo '("/home/reader/Mail/tmp/awk-work/13" "/home/reader/Mail/tmp/awk-work/14")) This is sort of like saying FOO="/home/reader/Mail/tmp/awk-work/13 /home/reader/Mail/tmp/awk-work/14" in a shell, because you separate elements in a shell list with whitespace. In the same way that you could then say (in bash) for x in $FOO; do cat $x; done you can say (dolist (x foo) (shell-command-to-string (concat "cat " x))) Of course, Lisp lists are tons better, because they don't get confused by whitespace, can store any kind of object, and get automatically freed when you're done with them :) > I'm guessing this is like a simple `for loop' and cat will be run on > each member in turn. So with just 1 member then maybe just on it. Right. > (mapcar (lambda (x) (shell-command-to-string (concat "cat " x))) > /home/reader/Mail/tmp/awk-work/13) > > So C-x C-e > Symbol's value as variable is void: \ > /home/reader/Mail/tmp/awk-work/13 Well, what you want to say here is: (mapcar (lambda (x) (shell-command-to-string (concat "cat " x))) '("/home/reader/Mail/tmp/awk-work/13")) So what you're doing here is creating a one-element list, with a string as its single element. > Well, I'm getting closer... May sound terribly lame, but I don't even > have a clue on how to begin looking this up in the Into or Lisp > manual. The Elisp intro is very good, and worth reading. > Good thing this isn't explosive... I'd have had a serious accident > by now. I still get that feeling pretty often :) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Mechaincal question Show filename of # marked 2000-12-22 5:10 ` Harry Putnam 2000-12-22 6:05 ` Colin Walters @ 2000-12-22 8:44 ` Kai Großjohann 1 sibling, 0 replies; 10+ messages in thread From: Kai Großjohann @ 2000-12-22 8:44 UTC (permalink / raw) Cc: ding On 21 Dec 2000, Harry Putnam wrote: > (mapcar (lambda (x) (shell-command-to-string (concat "cat " x))) > "/home/reader/Mail/tmp/awk-work/13") > > C-x C-e > > ("cat: 47: No such file or directory > " "cat: 104: No such file or directory > " "cat: 111: No such file or directory I'm sure you're wondering what happened here. Well, mapcar can iterate (go) over a list as well as any other sequence. And a string is just a sequence of characters. So what the mapcar was doing was applying the lambda to the character "/", then "h", then "o", and so on. And in Emacs Lisp, the character "/" is the same as its ascii code. And what's the ascii code of "/"? -- Right, 47. So this was executing "cat 47", then "cat 104", ... Colin has told you how to correct the problem, I just thought you might like to know what's happening. kai -- ~/.signature ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Mechaincal question Show filename of # marked 2000-12-21 15:55 ` Harry Putnam 2000-12-22 3:15 ` Colin Walters @ 2000-12-22 8:40 ` Kai Großjohann 1 sibling, 0 replies; 10+ messages in thread From: Kai Großjohann @ 2000-12-22 8:40 UTC (permalink / raw) Cc: ding On 21 Dec 2000, Harry Putnam wrote: > How can I feed that list to a shell script? Can I pipe it to a shell > script some how? Let X be a list of strings ("one" "two" "three"). Suppose you want to run the following shell command: ./foo one two three This can be done as follows: (mapconcat 'identity X " ") will produce a string "one two three" from the list. Then you just need to tack on "./foo " to the beginning and feed the rest to `shell-command': (shell-command (concat "./foo " (mapconcat 'identity X " "))) You can also use `call-process' but there you will have to deal with a little Lisp knowledge. `call-process' directly calls the program in question, without going through a shell. Now the other question: piping the list of filenames to the command on stdin. That's also possible. In principle, you start the program using `start-process'. The return value is a process object, and then you can send input to this process using the `process-send-string' function. This function needs the process object plus the string to send. After the last string, you can use `process-send-eof' to send end-of-file to the process. For going over the list and sending each string to the process, you can use mapcar as suggested by Colin. kai -- ~/.signature ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2000-12-22 8:44 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2000-12-21 3:06 Mechaincal question Show filename of # marked Harry Putnam 2000-12-21 10:02 ` Kai Großjohann 2000-12-21 14:28 ` Harry Putnam 2000-12-21 15:42 ` Kai Großjohann 2000-12-21 15:55 ` Harry Putnam 2000-12-22 3:15 ` Colin Walters 2000-12-22 5:10 ` Harry Putnam 2000-12-22 6:05 ` Colin Walters 2000-12-22 8:44 ` Kai Großjohann 2000-12-22 8:40 ` Kai Großjohann
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).