Gnus development mailing list
 help / color / mirror / Atom feed
* Q: Use external editor for Gnus?
@ 2001-10-22 21:07 Kai Großjohann
  2001-10-23  2:44 ` Daniel Pittman
  0 siblings, 1 reply; 9+ messages in thread
From: Kai Großjohann @ 2001-10-22 21:07 UTC (permalink / raw)


Can you believe it; this is actually a question asked in
de.comm.software.newsreader.misc!  (Or was it
de.comm.software.mailreader?)

What can we say?

Surely Gnus is so powerful, this must be possible, right?  Oh, boy,
oh, boy.

kai
-- 
Lisp is kinda like tpircstsoP



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Q: Use external editor for Gnus?
  2001-10-22 21:07 Q: Use external editor for Gnus? Kai Großjohann
@ 2001-10-23  2:44 ` Daniel Pittman
  2001-10-23  8:12   ` Kai Großjohann
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Pittman @ 2001-10-23  2:44 UTC (permalink / raw)


On Mon, 22 Oct 2001, Kai Großjohann wrote:
> Can you believe it; this is actually a question asked in
> de.comm.software.newsreader.misc!  (Or was it
> de.comm.software.mailreader?)
> 
> What can we say?

That is so, so, so very wrong. :)

> Surely Gnus is so powerful, this must be possible, right?  Oh, boy,
> oh, boy.

Presumably you could write your own message mode hook that would invoke
the external editor and stuff. But ... why?

        Daniel

-- 
You know you'll always be drifting
You know you'll never be found
A servant, so empty, you'll never make a sound
        -- Switchblade Symphony, _Naked Birthday_



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Q: Use external editor for Gnus?
  2001-10-23  2:44 ` Daniel Pittman
@ 2001-10-23  8:12   ` Kai Großjohann
  2001-10-23  8:52     ` Daniel Pittman
  2001-10-23 13:53     ` Samuel Padgett
  0 siblings, 2 replies; 9+ messages in thread
From: Kai Großjohann @ 2001-10-23  8:12 UTC (permalink / raw)
  Cc: ding

Daniel Pittman <daniel@rimspace.net> writes:

> Presumably you could write your own message mode hook that would invoke
> the external editor and stuff. But ... why?

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!

Now, if they were addicted to vi keybindings, we could just tell them
to use viper.  But with vim keybindings?

kai
-- 
Lisp is kinda like tpircstsoP



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Q: Use external editor for Gnus?
  2001-10-23  8:12   ` Kai Großjohann
@ 2001-10-23  8:52     ` Daniel Pittman
  2001-10-27 22:49       ` Florian Weimer
  2001-10-23 13:53     ` Samuel Padgett
  1 sibling, 1 reply; 9+ messages in thread
From: Daniel Pittman @ 2001-10-23  8:52 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]

On Tue, 23 Oct 2001, Kai Großjohann wrote:
> Daniel Pittman <daniel@rimspace.net> writes:
> 
>> Presumably you could write your own message mode hook that would
>> invoke the external editor and stuff. But ... why?
> 
> 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!
> 
> 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-emacs-lisp, Size: 1138 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]


-- 
Unix was not designed to stop people from doing stupid things,
because that would also stop them from doing clever things.
        -- Doug Gwyn

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Q: Use external editor for Gnus?
  2001-10-23  8:12   ` Kai Großjohann
  2001-10-23  8:52     ` Daniel Pittman
@ 2001-10-23 13:53     ` Samuel Padgett
  2001-10-23 15:03       ` Kai Großjohann
  1 sibling, 1 reply; 9+ messages in thread
From: Samuel Padgett @ 2001-10-23 13:53 UTC (permalink / raw)
  Cc: Daniel Pittman, ding

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:

> Now, if they were addicted to vi keybindings, we could just tell them
> to use viper.  But with vim keybindings?

FWIW, Vim has a lot of stuff that Viper doesn't.  Many key bindings
are, of course, the same: the "basic" Vi key bindings.  All of the
"window" commands are different, and Vim has a lot of ex commands that
just aren't defined in Viper.  Also, commands that operate on regions
are different.  But I think most of this wouldn't matter when just
composing mail.

One piece of advice, though: if they use Viper at a lower "expert
level", make sure they choose one high enough that ":q", ":wq", "Z Z",
and friends don't quit the editor.  In Mutt/Vim and slrn/Vim, these
are the keys you typically use to send the message.  (Actually, I
don't think it's possible to make :q or :wq to send the message
without hacking Viper internals, but it's easy to make "Z Z" do it.
There's even an example for this in the Viper manual.)

HTH,
Sam



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Q: Use external editor for Gnus?
  2001-10-23 13:53     ` Samuel Padgett
@ 2001-10-23 15:03       ` Kai Großjohann
  2001-10-24  2:30         ` Samuel Padgett
  0 siblings, 1 reply; 9+ messages in thread
From: Kai Großjohann @ 2001-10-23 15:03 UTC (permalink / raw)
  Cc: Daniel Pittman, ding

Samuel Padgett <spadgett1@nc.rr.com> writes:

> FWIW, Vim has a lot of stuff that Viper doesn't.

Yes.  Maybe someday somebody will write a ViMper extension...

kai
-- 
Lisp is kinda like tpircstsoP



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Q: Use external editor for Gnus?
  2001-10-23 15:03       ` Kai Großjohann
@ 2001-10-24  2:30         ` Samuel Padgett
  0 siblings, 0 replies; 9+ messages in thread
From: Samuel Padgett @ 2001-10-24  2:30 UTC (permalink / raw)
  Cc: Daniel Pittman, ding

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:

> Samuel Padgett <spadgett1@nc.rr.com> writes:
> 
>> FWIW, Vim has a lot of stuff that Viper doesn't.
> 
> Yes.  Maybe someday somebody will write a ViMper extension...

Personally, I'd be happy if Viper could emulate Vi flawlessly.
Viper's a terrific package, but it is still missing some Vi features.
If you try to run any moderately sophisticated ex commands, you'll
begin to see this.  (I've sent some patches to the author hoping to
correct a few of these incompatibilities.)

Sam



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Q: Use external editor for Gnus?
  2001-10-23  8:52     ` Daniel Pittman
@ 2001-10-27 22:49       ` Florian Weimer
  2001-10-28  9:37         ` Daniel Pittman
  0 siblings, 1 reply; 9+ messages in thread
From: Florian Weimer @ 2001-10-27 22:49 UTC (permalink / raw)


Daniel Pittman <daniel@rimspace.net> writes:

>   (let ((filename (make-temp-name "silly.vi.user."))
> 	(message  (current-buffer)))
>     (with-temp-buffer filename

This code results in a nasty /tmp race.  You should use
'make-temp-file' instead, or create a subdirectory in which you store
the file.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Q: Use external editor for Gnus?
  2001-10-27 22:49       ` Florian Weimer
@ 2001-10-28  9:37         ` Daniel Pittman
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Pittman @ 2001-10-28  9:37 UTC (permalink / raw)


On Sun, 28 Oct 2001, Florian Weimer wrote:
> Daniel Pittman <daniel@rimspace.net> writes:
> 
>>   (let ((filename (make-temp-name "silly.vi.user."))
>> 	(message  (current-buffer)))
>>     (with-temp-buffer filename
> 
> This code results in a nasty /tmp race.  

Creates a nasty race in the current working directory of Emacs,
actually, unless `make-temp-name' is different under Emacs than XEmacs.

> You should use 'make-temp-file' instead, or create a subdirectory in
> which you store the file.

It's not portable, nor is the FFI interface. :)  Seriously, though, even
the almost-latest XEmacs doesn't support `make-temp-file', which means
that I would need to emulate it...

Creating a directory in a world-writable folder wouldn't help. I really
should have done:

(let ((filename (expand-file-name (make-temp-name "silly.vi.user.") "~/")))
  ...

That would ensure that one of two things are true:
1) The rest of the world can't write the area the file is in.
2) The rest of the world can write '.emacs'[1], which means the user is
   losing anyway...

        Daniel

Footnotes: 
[1]  ...or .profile, or...

-- 
Show me a sane man and I will cure him for you.
        -- Carl Jung



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-10-28  9:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-22 21:07 Q: Use external editor for Gnus? Kai Großjohann
2001-10-23  2:44 ` Daniel Pittman
2001-10-23  8:12   ` Kai Großjohann
2001-10-23  8:52     ` Daniel Pittman
2001-10-27 22:49       ` Florian Weimer
2001-10-28  9:37         ` Daniel Pittman
2001-10-23 13:53     ` Samuel Padgett
2001-10-23 15:03       ` Kai Großjohann
2001-10-24  2:30         ` Samuel Padgett

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