From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/39637 Path: main.gmane.org!not-for-mail From: Daniel Pittman Newsgroups: gmane.emacs.gnus.general Subject: Re: Q: Use external editor for Gnus? Date: Tue, 23 Oct 2001 18:52:51 +1000 Organization: Not today, thank you, Mother. Sender: owner-ding@hpc.uh.edu Message-ID: <874roqu49o.fsf@inanna.rimspace.net> References: <87bsizjcsd.fsf@inanna.rimspace.net> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1035175317 29034 80.91.224.250 (21 Oct 2002 04:41:57 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 04:41:57 +0000 (UTC) Return-Path: Original-Received: (qmail 23887 invoked from network); 23 Oct 2001 08:53:56 -0000 Original-Received: from malifon.math.uh.edu (mail@129.7.128.13) by mastaler.com with SMTP; 23 Oct 2001 08:53:56 -0000 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 15vxJT-0006HM-00; Tue, 23 Oct 2001 03:53:31 -0500 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Tue, 23 Oct 2001 03:53:08 -0500 (CDT) Original-Received: from sclp3.sclp.com (qmailr@sclp3.sclp.com [209.196.61.66]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id DAA05887 for ; Tue, 23 Oct 2001 03:52:56 -0500 (CDT) Original-Received: (qmail 23488 invoked by alias); 23 Oct 2001 08:53:13 -0000 Original-Received: (qmail 23474 invoked from network); 23 Oct 2001 08:53:12 -0000 Original-Received: from melancholia.rimspace.net (HELO melancholia.danann.net) (210.23.138.19) by gnus.org with SMTP; 23 Oct 2001 08:53:12 -0000 Original-Received: from localhost (melancholia.rimspace.net [210.23.138.19]) by melancholia.danann.net (Postfix) with ESMTP id 544BE2A820 for ; Tue, 23 Oct 2001 18:52:55 +1000 (EST) Original-Received: by localhost (Postfix, from userid 1000) id E9FCE8210E; Tue, 23 Oct 2001 18:52:51 +1000 (EST) Original-To: ding@gnus.org In-Reply-To: (Kai.Grossjohann@CS.Uni-Dortmund.DE's message of "Tue, 23 Oct 2001 10:12:49 +0200") X-Homepage: http://danann.net/ Original-Lines: 73 User-Agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.5 (asparagus) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:39637 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:39637 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, 23 Oct 2001, Kai Gro=DFjohann wrote: > Daniel Pittman writes: >=20 >> Presumably you could write your own message mode hook that would >> invoke the external editor and stuff. But ... why? >=20 > They say, they're so accustomed to vim keybindings, they don't want to > switch. And actually, I can understand this. I'm equally addicted to > Emacs keybindings, after all! >=20 > Now, if they were addicted to vi keybindings, we could just tell them > to use viper. But with vim keybindings? Mostly the same, I believe. Anyway, in /theory/ you could do something like the attached Lisp, but it's pretty horrible. Oh, and untested, though I am almost tempted just to see how insane a thing I could put together. :) The code, as written, probably falls over in the following cases: 1. User kills the message buffer before the editor terminates. 2. Editor terminates uncleanly on startup. 3. Editor is canceled with no changes. 4. Multiple message buffers all at once. You could probably solve most of the issues, including the lack of closures, by making the code use buffer local values in the *message* buffer to store state. Heh. You know, I /must/ really want to avoid this mailing list setup I have to do. I would never have written something this silly otherwise. ;) Daniel --=-=-= Content-Type: text/x-emacs-lisp Content-Disposition: attachment (defun edit-buffer-in-vi () "Put the content of the buffer into an external file and invoke VI on it." (let ((filename (make-temp-name "silly.vi.user.")) (message (current-buffer))) (with-temp-buffer filename (insert (buffer-string message))) (let ((editor (start-process-shell-command "message editor" nil ; no associated buffer... "xterm" "-e" "vim" filename))) (cons editor filename)))) (defun edit-buffer-in-vi-make-closure (buffer filename) "Restore the content of buffer from filename when invoked." (let ((buffer-name (buffer-name buffer))) ; Oh for closures... `(lambda () (let ((buffer (get-buffer ,buffer-name))) (when buffer (with-current-buffer buffer (erase-buffer) (insert-file-contents ,filename))))))) (add-hook 'message-setup-hook ; am I the right hook? (lambda () "Invoke an external editor on the content of this buffer..." (let ((result (edit-buffer-in-vi))) (set-process-sentinel (car result) (edit-buffer-in-vi-make-closure (current-buffer) (cdr result)))))) --=-=-= -- Unix was not designed to stop people from doing stupid things, because that would also stop them from doing clever things. -- Doug Gwyn --=-=-=--