]> code.delx.au - gnu-emacs/blobdiff - lisp/dabbrev.el
(abs, ceiling, floor): Remove, since they now redefine
[gnu-emacs] / lisp / dabbrev.el
index 51e7d4954cb641b4e5b5b10f7998d0faa10c6270..d2f746b6c3191ae2eec155308f3ff59ef1028dc6 100644 (file)
@@ -1,11 +1,18 @@
-;; Dynamic abbreviation package for GNU Emacs.
+;;; dabbrev.el --- dynamic abbreviation package for GNU Emacs.
+
+;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
+
+;; Last-Modified: 16 Mar 1992
 ;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
 
+;; Maintainer: FSF
+;; Keywords: abbrev
+
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 1, or (at your option)
+;; the Free Software Foundation; either version 2, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -17,6 +24,7 @@
 ;; along with GNU Emacs; see the file COPYING.  If not, write to
 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
+;;; Commentary:
 
 ; DABBREVS - "Dynamic abbreviations" hack, originally written by Don Morrison
 ; for Twenex Emacs.  Converted to mlisp by Russ Fish.  Supports the table
 ; size limit variable.  Bugs fixed from the Twenex version are flagged by
 ; comments starting with ;;; .
 ; 
-; converted to elisp by Spencer Thomas.
+; converted to Emacs Lisp by Spencer Thomas.
 ; Thoroughly cleaned up by Richard Stallman.
 ;  
 ; If anyone feels like hacking at it, Bob Keller (Keller@Utah-20) first
 ; suggested the beast, and has some good ideas for its improvement, but
-; doesn?tknow TECO (the lucky devil...).  One thing that should definitely
+; doesn't know TECO (the lucky devil...).  One thing that should definitely
 ; be done is adding the ability to search some other buffer(s) if you can?t
 ; find the expansion you want in the current one.
 
+;;; Code:
+
 ;; (defun dabbrevs-help ()
 ;;   "Give help about dabbrevs."
 ;;   (interactive)
 ;;   (&info "emacs" "dabbrevs")        ; Select the specific info node.
 ;; )
-(provide 'dabbrevs)
-
 (defvar dabbrevs-limit nil
   "*Limits region searched by `dabbrevs-expand' to this many chars away.")
 (make-variable-buffer-local 'dabbrevs-limit)
@@ -154,8 +162,10 @@ with the next possible expansion not yet tried."
          (setq last-dabbrevs-abbrev-location nil)
          (if (not first)
              (progn (undo-boundary)
-                    (delete-backward-char (length old))
-                    (insert abbrev)))
+                    (search-backward old)
+                    (if (eq major-mode 'picture-mode)
+                        (picture-replace-match abbrev t 'literal)
+                      (replace-match abbrev t 'literal))))
          (error (if first
                     "No dynamic expansion for \"%s\" found."
                     "No further dynamic expansions for \"%s\" found.")
@@ -169,7 +179,9 @@ with the next possible expansion not yet tried."
       ;; First put back the original abbreviation with its original
       ;; case pattern.
       (save-excursion
-       (replace-match abbrev t 'literal))
+       (if (eq major-mode 'picture-mode)
+           (picture-replace-match abbrev t 'literal)
+         (replace-match abbrev t 'literal)))
       (search-forward abbrev)
       (let ((do-case (and do-case
                          (string= (substring expansion 1)
@@ -178,10 +190,16 @@ with the next possible expansion not yet tried."
        ;; case pattern.
        (save-excursion
          (replace-match abbrev t 'literal))
-       (search-forward abbrev)
-       (replace-match (if do-case (downcase expansion) expansion)
-                      (not do-case)
-                      'literal))
+;;; This used to be necessary, but no longer, 
+;;; because now point is preserved correctly above.
+;;;    (search-forward abbrev)
+       (if (eq major-mode 'picture-mode)
+           (picture-replace-match (if do-case (downcase expansion) expansion)
+                                  (not do-case)
+                                  'literal)
+         (replace-match (if do-case (downcase expansion) expansion)
+                        (not do-case)
+                        'literal)))
       ;; Save state for re-expand.
       (setq last-dabbrevs-abbreviation abbrev)
       (setq last-dabbrevs-expansion expansion)
@@ -256,3 +274,7 @@ with the next possible expansion not yet tried."
                     (= (point) beg))
                   (setq result (downcase result))))))
       result)))
+
+(provide 'dabbrev)
+
+;;; dabbrev.el ends here