Need help writing a few lines emacs lisp

Need help writing a few lines emacs lisp

Post by Willem Slu » Thu, 06 Apr 1995 04:00:00



Hi,

I am looking for a few lines of lisp code that will do the following.

After I've read my mail, and answered a couple of them, I want to
output all answered messages to a special file, e.g. mailanswered.

I don't think there is a standard function for this, so I want create
a new command, that ouputs all messages that have their "answered"
label set and then performs rmail-quit. Unfortunately, I'm not famiiar
with lisp at all.

Can someone help me out, or give me a pointer to a quick and simple
introduction of emacs lisp?

Thanks

----------------------------------------------+--------------------------
  Willem Sluis                                |

  California Institute of Technology          |
  Mailcode: 104-44                            |
  Pasadena, CA 91125                          |
----------------------------------------------+--------------------------

 
 
 

Need help writing a few lines emacs lisp

Post by Jari Aal » Sat, 08 Apr 1995 04:00:00



: Hi,
:
: I am looking for a few lines of lisp code that will do the following.
:
: After I've read my mail, and answered a couple of them, I want to
: output all answered messages to a special file, e.g. mailanswered.
:
: I don't think there is a standard function for this, so I want create
: a new command, that ouputs all messages that have their "answered"
: label set and then performs rmail-quit. Unfortunately, I'm not famiiar
: with lisp at all.
:
: Can someone help me out, or give me a pointer to a quick and simple
: introduction of emacs lisp?

The simplest, easiest and propable most common way is to
stick this into your .emacs:

(setq mail-archive-file-name "~/.RMAIL.out")
                                ^^^^^^^^^^^

In your case you want to change the output file name to "answered"
RMAIL adds every message you send, to this file, so you can quit
anytime you finish reading your mail.

Cheers!
--

IRC     |  -- Andre' Marrou virus --
orphee  | Erases unnecessary programs, disconnects your network and makes
        | yours  a stand-alone machine, improves productivity by eliminating
        | limits on resource allocation.

 
 
 

Need help writing a few lines emacs lisp

Post by Pablo Mej » Tue, 11 Apr 1995 04:00:00


    Willem> After I've read my mail, and answered a couple of them, I
    Willem> want to output all answered messages to a special file,
    Willem> e.g. mailanswered.

    Jari> The simplest, easiest and propable most common way is to
    Jari> stick this into your .emacs

    Jari> (setq mail-archive-file-name "~/.RMAIL.out") ^^^^^^^^^^^

    Jari> In your case you want to change the output file name to
    Jari> "answered" RMAIL adds every message you send, to this file,
    Jari> so you can quit anytime you finish reading your mail.

That archives OUTGOING messages.  What he wants is to archive messages
that he has replied to, not the replies.  The following works, but I
don't use rmail so it has not been stress tested.

(defun rmail-archive-answered ()
  (interactive)
  (rmail-maybe-set-message-counters)
  (let ((msg-num 1))
    (while (<= msg-num rmail-total-messages)
      (rmail-show-message msg-num)
      (if (rmail-message-labels-p msg-num ", ?\\(answered\\),")
          (progn
            (rmail-output "~/RMAIL-ANSWERED")
            (rmail-delete-message)))
      (setq msg-num (1+ msg-num))))
  (rmail-quit))

Pablo

 
 
 

1. Help writing emacs lisp function

Hello,

I need an emacs lisp function that does the following but I don't know
enough emacs lisp to write it myself and I'm kind-of pressed for time.
I suspect this will be child's play for some of the brilliant geniuses
who inhabit these ngs.

I will be eternally indebted.  Many TIA.
Kwon
[Post your replies here.  Do not e-mail them to me, please.]

--
(defun value-of-name-in-nvpairlist (nvlist name &optional default)
    "Return the value corresponding to NAME in the name-value pair
list NVLIST.  If NAME has no corresponding value in NVLIST and DEFAULT
is set, return DEFAULT, otherwise return NIL."
    ...
    ...
    ...)

nvlist is a list of this form ((foo someone) (bar set) (baz us) (ooka up))

1, b, iii, D are 'names' (strings).  someone, set, us, up are their
corresponding values (could be strings, integers, t/nil, lists,
anything else).  Names will occur only ONCE in the list.  That is,
((1 two) (1 three)) is not a possible nvlist.

Here's the expected behavior (using the nvlist defined above)

(value-of-name-in-nvpairlist foo) ==> someone
(value-of-name-in-nvpairlist ooka jnk) ==> up
(value-of-name-in-nvpairlist 5 the-bomb) ==> the-bomb

A possible algorithm [in pseudo-C] could be this:

{
    var value = NULL;
    var plist = nvlist;

    /* find the first match for name in list */
    while (plist) {
        if (car (car plist)) == name) {
            value = (cdr (car plist));
            break;
        } else
            plist = (cdr plist)
    }

    /* did we find a value? */
    if (value == NULL)
        value = (default == NULL) ? nil : default;
        /* i.e., if default is not set, return nil, else return default */

    return (value);

Could someone help me 'translate' this to Emacs-Lisp?  Thanks!

2. Mint IIc

3. Help with writing emacs-lisp code

4. black screen at startup

5. Help in writing lisp functions

6. Win 95 at BETT

7. Help in writing lisp code

8. Color space FAQ

9. need help writing IDL mode

10. HELP I need to write out a file...

11. need help writing a function

12. Help needed in Emacs-Lisp coding.

13. Novice needs help with emacs lisp expression