[geeks] quite

Greg A. Woods woods at weird.com
Mon Aug 5 15:42:56 CDT 2002


[ On Monday, August 5, 2002 at 12:00:16 (-0400), Joshua D Boyd wrote: ]
> Subject: Re: [geeks] quite
>
> I'm using mutt, which I seem to remember you disparaging in the past.

I've found even the most recent Mutt still sucks in the MIME department
despite that apparently being the primary focus for its update.

I've recently also been playing with some code borrowed from inside of
mutt (mostly just the address header parser), and that code is quite a
horrid hack too.  I'll probably ditch it, though if I can fix the most
insidious bugs then I'll actually submit some fixes and maybe try to
keep using it since it's smaller than the equivalent "correct" code.  :-)

> I am using emacs for editing.  I don't know how to make it invoke
> ispell-message on exit when editing mail messages.

assuming you're using emacsserver (as you should be, or at least
something like it), then you can just write a function which wraps
server-edit and does the right thing for Mutt buffers when you rebind
C-x # to it instead of to server-edit....

>  I did just give
> ispell-message a run, and I like it.  I think I need to find a hot key
> to assign it to for all plain text modes. 

If you're not already using mail-mode to edit your messages in then you
should find a way to make that happen first, then you can just do:

	(if (elisp-file-in-loadpath-p "ispell")
	    (add-hook mail-mode-hook
	              (function (lambda ()
			 (local-set-key "\C-ci" 'ispell-message))))

or maybe this:

	(if (elisp-file-in-loadpath-p "ispell")
	    (progn
	      (define-key mail-mode-map "\C-ci" 'ispell-message)
	      (define-key mail-mode-map "\M-S" 'ispell-message)))

(I actually use the first form for vm-mail-mode-hook, and the latter for
mail-mode, which seems to work for GNUS.)

As for other text modes, well you don't want to use ispell-message, but
rather just ispell-buffer.  Do this instead:

;;; This could probably be rewritten to use mapcar
(defun elisp-file-in-loadpath-p (file-name)
  "Returns t if there is an emacs lisp-library of the name FILENAME in
the load-path list. Matching is first done by looking for the file
with an .elc extension, an .el extension, and finally with no
extension at all, and returning t if any of the three are found. Nil
is returned otherwise."
  (let ((extension-list (list ".elc" ".el" ""))
        (file-found-p nil)
        name-to-try)
    (while (and (not file-found-p) (not (null extension-list)))
      (setq name-to-try (concat file-name (car extension-list)))
      (setq extension-list (cdr extension-list))
      (setq file-found-p (file-in-loadpath-p name-to-try)))
    (eval 'file-found-p)))

(defun file-in-loadpath-p (file-name)
  "Returns t if the string argument FILENAME is a file name present in a
directory in the load-path list, otherwise returns nil."
  (file-in-pathlist-p file-name load-path))

(defun file-in-pathlist-p (file-name path-list)
  "Returns t if the string FILENAME is a file name which occurs in a
directory in the list PATHLIST, otherwise nil."
  (let (try-path (file-found-in-path-p nil))
    (while (not (or file-found-in-path-p (null path-list)))
      (setq try-path (car path-list)
            path-list (cdr path-list))
      (if (file-exists-p (concat try-path "/" file-name)) ; path-separator :-)
          (setq file-found-in-path-p t)))
    (eval 'file-found-in-path-p)))

(add-hook 'text-mode-hook
	  (function
	   (lambda ()
	     "Private text-mode and indented-text-mode stuff."
	     ;; If for some reason the *scratch* buffer was killed earlier
	     ;; and is recreated here because all other buffers have been
	     ;; killed, then reset the major mode to emacs-lisp-mode.
	     ;; One disadvantage to this is that you can't put the
	     ;; *scratch* buffer in text mode without disabling this hook.
	     (if (equal (buffer-name) "*scratch*")
		 (emacs-lisp-mode)
	       (progn
		 ;;(override-local-key-settings)
		 ;;(override-default-variable-settings)
		 (if (elisp-file-in-loadpath-p "ispell")
		     (local-set-key "\eS" 'ispell-buffer)
		   (local-set-key "\eS" 'spell-buffer))
		 (setq abbrev-mode t)
		 (setq fill-column 72)
		 (setq require-final-newline t)	; needed by some unix programs
		 (turn-on-auto-fill))))))



You might find this useful too:

(if (elisp-file-in-loadpath-p "ispell")
    (progn
      ;; to quiet the v19 byte compiler
      (defvar ispell-filter-hook)
      (defvar ispell-filter-hook-args)
      (defvar plain-TeX-mode-hook)
      (defvar LaTeX-mode-hook)
      (defvar nroff-mode-hook)
      (require 'ispell)
      (define-key global-map "\M-S" 'ispell-buffer)
      (setq plain-TeX-mode-hook
	    (function
	     (lambda ()
	       (setq ispell-filter-hook "detex")
	       (setq ispell-filter-hook-args '("-nw")))))
      (setq LaTeX-mode-hook
	    (function
	     (lambda ()
	       (setq ispell-filter-hook "detex")
	       (setq ispell-filter-hook-args '("-lnw")))))
      (setq nroff-mode-hook
	    (function
	     (lambda ()
	       (setq ispell-filter-hook "deroff")
	       (setq ispell-filter-hook-args '("-w")))))))


Lots more emacs goodies in the .emacs.el contained in this archive:

	ftp://ftp.weird.com/pub/local/dotfiles.tar.gz

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods at ieee.org>;           <woods at robohack.ca>
Planix, Inc. <woods at planix.com>; VE3TCP; Secrets of the Weird <woods at weird.com>



More information about the geeks mailing list