[Users] External editor?

Barry Warsaw barry at python.org
Mon Nov 10 18:53:47 CET 2014

On Nov 09, 2014, at 09:37 AM, Ian Zimmerman wrote:

>No.  Emacs is not a clone of vi.  It doesn't support passing the mode on
>the command line in the same way.  That's what I was trying to say with
>my post.
>The closest analogue would be something like
>emacs --file %s --funcall claws-external-mode
>but there are complications, particularly when one uses the emacs
>server.  That's why I prefer the local variables trick instead.

Here's my dumb way of setting this up in emacs.  I've had this chunk of code
for years, so there are probably better ways of doing it, but it WFM.


(defun baw-os-path-split (filename)
  "Convert a file name into a list of its path components."
  (let ((path filename)
        last dir parts)
    (while path
      (setq last (file-name-nondirectory path)
            dir (file-name-directory path))
      ;; Remove any trailing slash.
      (if dir
          (setq path (substring (file-name-directory path) 0 -1))
        (setq path dir))
      (push last parts))

(defun baw-server-visit-hook ()
  (let* ((filename (buffer-file-name))
         (parts (and filename (reverse (baw-os-path-split filename))))
    (when parts
      (setq firstpart (pop parts))
      (when (and (>= (length firstpart) 6)
                 (string-equal (substring firstpart 0 6) "tmpmsg")
                 (string-equal (pop parts) "tmp")
                 (string-equal (pop parts) ".claws-mail"))
        ;; Claws mail temporary buffers should be mail buffers for syntax
        ;; highlighting.  I may want to turn off whitespace mode and other
        ;; syntax highlighting, but I'm not sure yet.
(add-hook 'server-visit-hook 'baw-server-visit-hook)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.claws-mail.org/pipermail/users/attachments/20141110/05fb9b25/attachment.sig>

More information about the Users mailing list