-;; expand.el --- make abbreviations more usable.
+;;; expand.el --- make abbreviations more usable
-;; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 2001, 2002, 2003, 2004,
+;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: Frederic Lepied <Frederic.Lepied@sugix.frmug.org>
;; Maintainer: Frederic Lepied <Frederic.Lepied@sugix.frmug.org>
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; 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 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; ("default" "default:\n\nbreak;" 10)
;; ("main" "int\nmain(int argc, char * argv[])\n{\n\n}\n" 37))
;; "Expansions for C mode")
-;;
+;;
;; and enter Abbrev mode with the following hook :
;;
-;; (add-hook 'c-mode-hook (function (lambda ()
-;; (expand-add-abbrevs c-mode-abbrev-table c-expand-list)
-;; (abbrev-mode))))
+;; (add-hook 'c-mode-hook
+;; (lambda ()
+;; (expand-add-abbrevs c-mode-abbrev-table c-expand-list)
+;; (abbrev-mode 1)))
;;
;; you can also init some post-process hooks :
;;
;; (add-hook 'expand-load-hook
-;; (function
-;; (lambda ()
-;; (add-hook 'expand-expand-hook 'indent-according-to-mode)
-;; (add-hook 'expand-jump-hook 'indent-according-to-mode))))
+;; (lambda ()
+;; (add-hook 'expand-expand-hook 'indent-according-to-mode)
+;; (add-hook 'expand-jump-hook 'indent-according-to-mode)))
;;
;; Remarks:
;;
;; Please send me a word to give me your feeling about this feature or
;; to explain me how you use it (your expansions table for example) using
;; the function expand-submit-report.
+;;; Code:
\f
;;; Constants:
-(defvar expand-load-hook nil
- "Hooks run when `expand.el' is loaded.")
+(defgroup expand nil
+ "Make abbreviations more usable."
+ :group 'abbrev)
-(defvar expand-expand-hook nil
- "Hooks run when an abbrev made by `expand-add-abbrevs' is expanded.")
+(defcustom expand-load-hook nil
+ "Hooks run when `expand.el' is loaded."
+ :type 'hook
+ :group 'expand)
-(defvar expand-jump-hook nil
- "Hooks run by `expand-jump-to-previous-slot' and `expand-jump-to-next-slot'.")
+(defcustom expand-expand-hook nil
+ "Hooks run when an abbrev made by `expand-add-abbrevs' is expanded."
+ :type 'hook
+ :group 'expand)
+
+(defcustom expand-jump-hook nil
+ "Hooks run by `expand-jump-to-previous-slot' and `expand-jump-to-next-slot'."
+ :type 'hook
+ :group 'expand)
;;; Samples:
"Loop var: "
"for(" str _ @ "=0; " str @ "; " str @ ") {" \n
@ _ \n
- "}" >
- )
+ "}" > \n)
(defconst expand-c-sample-expand-list
'(("if" "if () {\n \n} else {\n \n}" (5 10 21))
(concat
"(defmacro ()\n"
" \"\"\n"
- " (` \n"
+ " `( \n"
" ))")
(list 11 13 18 25))
)
"Expansions for Lisp mode. See `expand-add-abbrevs'.")
-
+
;; perl example from Jari Aalto <jaalto@tre.tele.nokia.fi>
(defconst expand-sample-perl-mode-expand-list
(list
(defvar expand-list nil "Temporary variable used by the Expand package.")
(defvar expand-pos nil
- "If non nil, stores a vector containing markers to positions defined by the last expansion.
+ "If non-nil, stores a vector containing markers to positions defined by the last expansion.
This variable is local to a buffer.")
(make-variable-buffer-local 'expand-pos)
'expand-abbrev-hook)))
(put 'expand-abbrev-hook 'no-self-insert t)
+;;;###autoload
(defun expand-abbrev-hook ()
"Abbrev hook used to do the expansion job of expand abbrevs.
-See `expand-add-abbrevs'."
+See `expand-add-abbrevs'. Value is non-nil if expansion was done."
;; Expand only at the end of a line if we are near a word that has
;; an abbrev built from expand-add-abbrev.
(if (and (eolp)
expand-pos (expand-list-to-markers expand-list)
expand-list nil)))
(run-hooks 'expand-expand-hook)
- t))))
- )
+ t)
+ nil))
+ nil))
(defun expand-do-expansion ()
(delete-backward-char (length last-abbrev-text))
(goto-char (aref expand-pos expand-index))
(run-hooks 'expand-jump-hook))))
-;;;###autoload (define-key ctl-x-map "ap" 'expand-jump-to-previous-slot)
-;;;###autoload (define-key ctl-x-map "an" 'expand-jump-to-next-slot)
+;;;###autoload (define-key abbrev-map "p" 'expand-jump-to-previous-slot)
+;;;###autoload (define-key abbrev-map "n" 'expand-jump-to-next-slot)
(defun expand-build-list (len l)
"Build a vector of offset positions from the list of positions."
(defun expand-skeleton-end-hook ()
(if skeleton-positions
(setq expand-list skeleton-positions)))
-
+
(add-hook 'skeleton-end-hook (function expand-skeleton-end-hook))
(provide 'expand)
;; run load hooks
(run-hooks 'expand-load-hook)
+;; arch-tag: fee53e9e-30e3-4ef3-b191-9785e1f8e885
;;; expand.el ends here