[comp.emacs] LaTeX and spell

pabuhr@watmsg.UUCP (08/03/87)

I had a problem with spell-region not working very well on LaTex files
so I looked through spell.el to see if there was an easy way to pass
the -l flag to spell so that it would ignore LaTeX constructions.  No
such luck. So I hacked out the following modification to spell.el that
checks if the major-mode is either LaTeX-mode or TeX-mode, and if so,
passes the -l flag to spell. Disclaimer: I am not a Lisper nor do I
know much about the insides of emacs; hence, there might be a better
way to do this. If there is, please let me know.  The following is the
diff of my stuff and spell.el. We are running BSD 4.3 and GnuEmacs 18.47.

49,53c49
<   (let ((buf (get-buffer-create " *temp*"))
< 	(spell-flags (if (or (string-equal "LaTeX-mode" major-mode) ; set spell-flag to "-l" if buffer mode
< 			     (string-equal "TeX-mode" major-mode))  ;    is LaTeX or TeX
< 			 "-l" ; tell spell to ignore LaTeX constructions, assuming -t is a subset of -l
< 		       "")))
---
>   (let ((buf (get-buffer-create " *temp*")))
61c57
< 			     nil buf nil spell-flags)
---
> 			     nil buf)
68c64
< 			      t buf nil spell-flags))))
---
> 			      t buf))))

jr@LF-SERVER-2.BBN.COM (John Robinson) (08/05/87)

The LaTeX distribution comes with a "delatex" filter.  What I do is to
define a private version of spell as follows:

  delatex $1 | /usr/bin/spell

/usr/bin/spell is also a shell script; if you look at it you will find
it runs a filter called 'deroff'.  If you never care about nroff/troff
input to spell, you could replace calls to deroff with calls to
delatex in a private version of spell, or install delatex in place of
deroff.

/jr

seindal@diku.UUCP (Rene Seindal) (08/06/87)

Heres a diff to spell.el which makes i possible to use any spelling
checker.  It used a variable "spell-program" to specify the spelling checker
to use.  It is set to "spell" by default, but it can be made local to any
buffer to specify another program.

Rene' Seindal (seindal@diku.uucp)
The Computer Department, Institute of Datalogy, U. of Copenhagen.

-- CUT HERE ----------------------------------------------------------
*** /usr/src/new/emacs/lisp/spell.el	Tue Sep 30 18:13:46 1986
--- /usr/staff/seindal/emacs/src/spell.el	Thu Aug  6 11:05:46 1987
***************
*** 18,24 ****
--- 18,28 ----
  ;; file named COPYING.  Among other things, the copyright notice
  ;; and this notice must be preserved on all copies.
  
+ ;; Rene Seindal (seindal@diku.dikunet) Tue May 19 10:27:52 1987 
+ ;; Introduced variable spell-program.
  
+ (defvar spell-program "spell" "*Program to use for spelling checks")
+ 
  (defun spell-buffer ()
    "Check spelling of every word in the buffer.
  For each incorrect word, you are asked for the correct spelling
***************
*** 53,59 ****
       (erase-buffer))
      (message "Checking spelling of %s..." (or description "region"))
      (if (= ?\n (char-after (1- end)))
! 	(call-process-region start end "spell"
  			     nil buf)
        (let ((oldbuf (current-buffer)))
  	(save-excursion
--- 57,63 ----
       (erase-buffer))
      (message "Checking spelling of %s..." (or description "region"))
      (if (= ?\n (char-after (1- end)))
! 	(call-process-region start end spell-program
  			     nil buf)
        (let ((oldbuf (current-buffer)))
  	(save-excursion
***************
*** 60,67 ****
  	 (set-buffer buf)
  	 (insert-buffer-substring oldbuf start end)
  	 (insert ?\n)
! 	 (call-process-region (point-min) (point-max) "spell"
! 			      t buf))))
      (message "Checking spelling of %s...%s"
  	     (or description "region")
  	     (if (save-excursion
--- 64,71 ----
  	 (set-buffer buf)
  	 (insert-buffer-substring oldbuf start end)
  	 (insert ?\n)
! 	 (call-process-region (point-min) (point-max) spell-program
! 			      t buf ))))
      (message "Checking spelling of %s...%s"
  	     (or description "region")
  	     (if (save-excursion
***************
*** 101,107 ****
       (widen)
       (erase-buffer)
       (insert string "\n")
!      (call-process-region (point-min) (point-max) "spell"
  			  t t)
       (if (= 0 (buffer-size))
  	 (message "%s is correct" string)
--- 105,111 ----
       (widen)
       (erase-buffer)
       (insert string "\n")
!      (call-process-region (point-min) (point-max) spell-program
  			  t t)
       (if (= 0 (buffer-size))
  	 (message "%s is correct" string)