diff lisp/modes/abbrev.el @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children 85ec50267440
line wrap: on
line diff
--- a/lisp/modes/abbrev.el	Mon Aug 13 08:45:53 2007 +0200
+++ b/lisp/modes/abbrev.el	Mon Aug 13 08:46:35 2007 +0200
@@ -1,7 +1,8 @@
-;;; abbrev.el ---  abbrev mode commands for Emacs
+;;; abbrev.el --- abbrev mode commands for Emacs
 
-;; Copyright (C) 1985, 1986, 1992, 1993 Free Software Foundation, Inc.
-;; Keywords: internal, abbrev
+;; Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
+
+;; Keywords: abbrev
 
 ;; This file is part of XEmacs.
 
@@ -17,14 +18,23 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
-;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+;; 02111-1307, USA.
+
+;;; Synched up with: FSF 19.34 (With some additions)
+
+;;; Commentary:
+
+;; This facility is documented in the Emacs Manual.
+
+;;; Code:
 
 ;jwz: this is preloaded so don't ;;;###autoload
-(defconst only-global-abbrevs nil
-  "*t means user plans to use global abbrevs only.
-Makes the commands to define mode-specific abbrevs define global ones instead."
-  )
+(defconst only-global-abbrevs nil "\
+*t means user plans to use global abbrevs only.
+Makes the commands to define mode-specific abbrevs define global ones instead.")
 
+;;; XEmacs: the following block of code is not in FSF
 (defvar abbrev-table-name-list '()
   "List of symbols whose values are abbrev tables.")
 
@@ -234,17 +244,18 @@
           (princ "    \)\)\n" stream)))
     (terpri stream))
   (message ""))
-
+;;; End code not in FSF
 
 (defun abbrev-mode (arg)
   "Toggle abbrev mode.
-With arg, turn abbrev mode on iff arg is positive.
+With argument ARG, turn abbrev mode on iff ARG is positive.
 In abbrev mode, inserting an abbreviation causes it to expand
 and be replaced by its expansion."
   (interactive "P")
   (setq abbrev-mode
 	(if (null arg) (not abbrev-mode)
 	  (> (prefix-numeric-value arg) 0)))
+  ;; XEmacs change
   (redraw-modeline))
 
 
@@ -253,6 +264,7 @@
 (if edit-abbrevs-map
     nil
   (setq edit-abbrevs-map (make-sparse-keymap))
+  ;; XEmacs change
   (set-keymap-name edit-abbrevs-map 'edit-abbrevs-map)
   (define-key edit-abbrevs-map "\C-x\C-s" 'edit-abbrevs-redefine)
   (define-key edit-abbrevs-map "\C-c\C-c" 'edit-abbrevs-redefine))
@@ -306,7 +318,7 @@
 (defun edit-abbrevs ()
   "Alter abbrev definitions by editing a list of them.
 Selects a buffer containing a list of abbrev definitions.
-You can edit them and type C-c C-c to redefine abbrevs
+You can edit them and type \\<edit-abbrevs-map>\\[edit-abbrevs-redefine] to redefine abbrevs
 according to your editing.
 Buffer contains a header line for each abbrev table,
  which is the abbrev table name in parentheses.
@@ -326,7 +338,7 @@
 
 (defun define-abbrevs (&optional arg)
   "Define abbrevs according to current visible buffer contents.
-See documentation of edit-abbrevs for info on the format of the
+See documentation of `edit-abbrevs' for info on the format of the
 text you must have in the buffer.
 With argument, eliminate all abbrev definitions except
 the ones defined from the buffer now."
@@ -337,24 +349,22 @@
    (while (and (not (eobp)) (re-search-forward "^(" nil t))
      (let* ((buf (current-buffer))
 	    (table (read buf))
-	    (abbrevs '()))
+	    abbrevs name hook exp count)
        (forward-line 1)
        (while (progn (forward-line 1)
 		     (not (eolp)))
-	 (let* ((name (read buf))
-                (count (read buf))
-                (exp (read buf))
-                hook)
-           (skip-chars-backward " \t\n\f")
-           (setq hook (if (not (eolp)) (read buf)))
-           (skip-chars-backward " \t\n\f")
-           (setq abbrevs (cons (list name exp hook count) abbrevs))))
+	 (setq name (read buf) count (read buf) exp (read buf))
+	 (skip-chars-backward " \t\n\f")
+	 (setq hook (if (not (eolp)) (read buf)))
+	 (skip-chars-backward " \t\n\f")
+	 (setq abbrevs (cons (list name exp hook count) abbrevs)))
        (define-abbrev-table table abbrevs)))))
 
 (defun read-abbrev-file (&optional file quietly)
-  "Read abbrev definitions from file written with write-abbrev-file.
-Takes file name as argument.
-Optional second argument non-nil means don't print anything."
+  "Read abbrev definitions from file written with `write-abbrev-file'.
+Optional argument FILE is the name of the file to read;
+it defaults to the value of `abbrev-file-name'.
+Optional second argument QUIETLY non-nil means don't print anything."
   (interactive "fRead abbrev file: ")
   (load (if (and file (> (length file) 0)) file abbrev-file-name)
 	nil quietly)
@@ -362,13 +372,16 @@
 
 (defun quietly-read-abbrev-file (&optional file)
   "Read abbrev definitions from file written with write-abbrev-file.
-Takes file name as argument.  Does not print anything."
+Optional argument FILE is the name of the file to read;
+it defaults to the value of `abbrev-file-name'.
+Does not print anything."
   ;(interactive "fRead abbrev file: ")
   (read-abbrev-file file t))
 
 (defun write-abbrev-file (file)
-  "Write all abbrev definitions to file of Lisp code.
-The file can be loaded to define the same abbrevs."
+  "Write all abbrev definitions to a file of Lisp code.
+The file written can be loaded in another session to define the same abbrevs.
+The argument FILE is the file name to write."
   (interactive
    (list
     (read-file-name "Write abbrev file: "
@@ -387,30 +400,30 @@
    (erase-buffer)))
 
 (defun add-mode-abbrev (arg)
-  "Define mode-specific abbrev for region or last word(s) before point.
+  "Define mode-specific abbrev for last word(s) before point.
 Argument is how many words before point form the expansion;
 or zero means the region is the expansion.
 A negative argument means to undefine the specified abbrev.
 Reads the abbreviation in the minibuffer.
 
-Don't use this function in a Lisp program; use define-abbrev instead."
+Don't use this function in a Lisp program; use `define-abbrev' instead."
   ;; XEmacs change:
   (interactive "P")
-  (add-abbrev (if only-global-abbrevs
-		  global-abbrev-table 
-		(or local-abbrev-table
-		    (error "No per-mode abbrev table.")))
-	      "Mode"
-	      arg))
+  (add-abbrev
+   (if only-global-abbrevs
+       global-abbrev-table 
+     (or local-abbrev-table
+	 (error "No per-mode abbrev table")))
+   "Mode" arg))
 
 (defun add-global-abbrev (arg)
-  "Define global (all modes) abbrev for region or last word(s) before point.
-Argument is how many words before point form the expansion;
-or zero means the region is the expansion.
+  "Define global (all modes) abbrev for last word(s) before point.
+The prefix argument specifies the number of words before point that form the
+expansion; or zero means the region is the expansion.
 A negative argument means to undefine the specified abbrev.
-Reads the abbreviation in the minibuffer.
+This command uses the minibuffer to read the abbreviation.
 
-Don't use this function in a Lisp program; use define-abbrev instead."
+Don't use this function in a Lisp program; use `define-abbrev' instead."
   ;; XEmacs change:
   (interactive "P")
   (add-abbrev global-abbrev-table "Global" arg))
@@ -429,6 +442,7 @@
 	  (read-string (format (if exp "%s abbrev for \"%s\": "
 				 "Undefine %s abbrev: ")
 			       type exp)))
+    (set-text-properties 0 (length name) nil name)
     (if (or (null exp)
 	    (not (abbrev-expansion name table))
 	    (y-or-n-p (format "%s expands to \"%s\"; redefine? "
@@ -437,21 +451,21 @@
 	
 (defun inverse-add-mode-abbrev (arg)
   "Define last word before point as a mode-specific abbrev.
-With argument N, defines the Nth word before point.
-Reads the expansion in the minibuffer.
+With prefix argument N, defines the Nth word before point.
+This command uses the minibuffer to read the expansion.
 Expands the abbreviation after defining it."
   (interactive "p")
-  (inverse-add-abbrev (if only-global-abbrevs
-			  global-abbrev-table 
-			(or local-abbrev-table
-			    (error "No per-mode abbrev table.")))
-		      "Mode"
-		      arg))
+  (inverse-add-abbrev
+   (if only-global-abbrevs
+       global-abbrev-table 
+     (or local-abbrev-table
+	 (error "No per-mode abbrev table")))
+   "Mode" arg))
 
 (defun inverse-add-global-abbrev (arg)
   "Define last word before point as a global (mode-independent) abbrev.
-With argument N, defines the Nth word before point.
-Reads the expansion in the minibuffer.
+With prefix argument N, defines the Nth word before point.
+This command uses the minibuffer to read the expansion.
 Expands the abbreviation after defining it."
   (interactive "p")
   (inverse-add-abbrev global-abbrev-table "Global" arg))
@@ -462,6 +476,7 @@
      (forward-word (- arg))
      (setq name (buffer-substring (point) (progn (forward-word 1)
 					       (setq nameloc (point))))))
+    (set-text-properties 0 (length name) nil name)
     (setq exp (read-string (format "%s expansion for \"%s\": "
 				   type name)))
     (if (or (not (abbrev-expansion name table))
@@ -475,10 +490,9 @@
 
 (defun abbrev-prefix-mark (&optional arg)
   "Mark current point as the beginning of an abbrev.
-Abbrev to be expanded starts here rather than at
-beginning of word.  This way, you can expand an abbrev
-with a prefix: insert the prefix, use this command,
-then insert the abbrev."
+Abbrev to be expanded starts here rather than at beginning of word.
+This way, you can expand an abbrev with a prefix: insert the prefix,
+use this command, then insert the abbrev."
   (interactive "P")
   (or arg (expand-abbrev))
   (setq abbrev-start-location (point-marker)
@@ -488,8 +502,8 @@
 (defun expand-region-abbrevs (start end &optional noquery)
   "For abbrev occurrence in the region, offer to expand it.
 The user is asked to type y or n for each occurrence.
-A numeric argument means don't query; expand all abbrevs.
-Calling from a program, arguments are START END &optional NOQUERY."
+A prefix argument means don't query; expand all abbrevs.
+If called from a Lisp program, arguments are START END &optional NOQUERY."
   (interactive "r\nP")
   (save-excursion
     (goto-char start)
@@ -505,3 +519,5 @@
 		    pnt)))
 	    (if (or noquery (y-or-n-p (format "Expand `%s'? " string)))
 		(expand-abbrev)))))))
+
+;;; abbrev.el ends here