comparison lisp/abbrev.el @ 814:a634e3b7acc8

[xemacs-hg @ 2002-04-14 12:41:59 by ben] latest changes TODO.ben-mule-21-5: Update. make-docfile.c: Add basic support for handling ISO 2022 doc strings -- we parse the basic charset designation sequences so we know whether we're in ASCII and have to pay attention to end quotes and such. Reformat code according to coding standards. abbrev.el: Add `global-abbrev-mode', which turns on or off abbrev-mode in all buffers. Added `defining-abbrev-turns-on-abbrev-mode' -- if non-nil, defining an abbrev through an interactive function will automatically turn on abbrev-mode, either globally or locally depending on the command. This is the "what you'd expect" behavior. indent.el: general function for indenting a balanced expression in a mode-correct way. Works similar to indent-region in that a mode can specify a specific command to do the whole operation; if not, figure out the region using forward-sexp and indent each line using indent-according-to-mode. keydefs.el: Removed. Modify M-C-backslash to do indent-region-or-balanced-expression. Make S-Tab just insert a TAB char, like it's meant to do. make-docfile.el: Now that we're using the call-process-in-lisp, we need to load an extra file win32-native.el because we're running a bare temacs. menubar-items.el: Totally redo the Cmds menu so that most used commands appear directly on the menu and less used commands appear in submenus. The old way may have been very pretty, but rather impractical. process.el: Under Windows, don't ever use old-call-process-internal, even in batch mode. We can do processes in batch mode. subr.el: Someone recoded truncate-string-to-width, saying "the FSF version is too complicated and does lots of hard-to-understand stuff" but the resulting recoded version was *totally* wrong! it misunderstood the basic point of this function, which is work in *columns* not chars. i dumped ours and copied the version from FSF 21.1. Also added truncate-string-with-continuation-dots, since this idiom is used often. config.inc.samp, xemacs.mak: Separate out debug and optimize flags. Remove all vestiges of USE_MINIMAL_TAGBITS, USE_INDEXED_LRECORD_IMPLEMENTATION, and GUNG_HO, since those ifdefs have long been removed. Make error-checking support actually work. Some rearrangement of config.inc.samp to make it more logical. Remove callproc.c and ntproc.c from xemacs.mak, no longer used. Make pdump the default. lisp.h: Add support for strong type-checking of Bytecount, Bytebpos, Charcount, Charbpos, and others, by making them classes, overloading the operators to provide integer-like operation and carefully controlling what operations are allowed. Not currently enabled in C++ builds because there are still a number of compile errors, and it won't really work till we merge in my "8-bit-Mule" workspace, in which I make use of the new types Charxpos, Bytexpos, Memxpos, representing a "position" either in a buffer or a string. (This is especially important in the extent code.) abbrev.c, alloc.c, eval.c, buffer.c, buffer.h, editfns.c, fns.c, text.h: Warning fixes, some of them related to new C++ strict type checking of Bytecount, Charbpos, etc. dired.c: Caught an actual error due to strong type checking -- char len being passed when should be byte len. alloc.c, backtrace.h, bytecode.c, bytecode.h, eval.c, sysdep.c: Further optimize Ffuncall: -- process arg list at compiled-function creation time, converting into an array for extra-quick access at funcall time. -- rewrite funcall_compiled_function to use it, and inline this function. -- change the order of check for magic stuff in SPECBIND_FAST_UNSAFE to be faster. -- move the check for need to garbage collect into the allocation code, so only a single flag needs to be checked in funcall. buffer.c, symbols.c: add debug funs to check on mule optimization info in buffers and strings. eval.c, emacs.c, text.c, regex.c, scrollbar-msw.c, search.c: Fix evil crashes due to eistrings not properly reinitialized under pdump. Redo a bit some of the init routines; convert some complex_vars_of() into simple vars_of(), because they didn't need complex processing. callproc.c, emacs.c, event-stream.c, nt.c, process.c, process.h, sysdep.c, sysdep.h, syssignal.h, syswindows.h, ntproc.c: Delete. Hallelujah, praise the Lord, there is no god but Allah!!! fix so that processes can be invoked in bare temacs -- thereby eliminating any need for callproc.c. (currently only eliminated under NT.) remove all crufty and unnecessary old process code in ntproc.c and elsewhere. move non-callproc-specific stuff (mostly environment) into process.c, so callproc.c can be left out under NT. console-tty.c, doc.c, file-coding.c, file-coding.h, lstream.c, lstream.h: fix doc string handling so it works with Japanese, etc docs. change handling of "character mode" so callers don't have to manually set it (quite error-prone). event-msw.c: spacing fixes. lread.c: eliminate unused crufty vintage-19 "FSF defun hack" code. lrecord.h: improve pdump description docs. buffer.c, ntheap.c, unexnt.c, win32.c, emacs.c: Mule-ize some unexec and startup code. It was pseudo-Mule-ized before by simply always calling the ...A versions of functions, but that won't cut it -- eventually we want to be able to run properly even if XEmacs has been installed in a Japanese directory. (The current problem is the timing of the loading of the Unicode tables; this will eventually be fixed.) Go through and fix various other places where the code was not Mule-clean. Provide a function mswindows_get_module_file_name() to get our own name without resort to PATH_MAX and such. Add a big comment in main() about the problem with Unicode table load timing that I just alluded to. emacs.c: When error-checking is enabled (interpreted as "user is developing XEmacs"), don't ask user to "pause to read messages" when a fatal error has occurred, because it will wedge if we are in an inner modal loop (typically when a menu is popped up) and make us unable to get a useful stack trace in the debugger. text.c: Correct update_entirely_ascii_p_flag to actually work. lisp.h, symsinit.h: declarations for above changes.
author ben
date Sun, 14 Apr 2002 12:43:31 +0000
parents 1ccc32a20af4
children 69c43a181729
comparison
equal deleted inserted replaced
813:9541922fb765 814:a634e3b7acc8
1 ;;; abbrev.el --- abbrev mode commands for Emacs 1 ;;; abbrev.el --- abbrev mode commands for Emacs
2 2
3 ;; Copyright (C) 1985, 1986, 1987, 1992, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1985, 1986, 1987, 1992, 1997 Free Software Foundation, Inc.
4 ;; Copyright (C) 2002 Ben Wing.
4 5
5 ;; Maintainer: XEmacs Development Team 6 ;; Maintainer: XEmacs Development Team
6 ;; Keywords: abbrev, dumped 7 ;; Keywords: abbrev, dumped
7 8
8 ;; This file is part of XEmacs. 9 ;; This file is part of XEmacs.
35 (defgroup abbrev nil 36 (defgroup abbrev nil
36 "Abbreviation handling, typing shortcuts, macros." 37 "Abbreviation handling, typing shortcuts, macros."
37 :tag "Abbreviations" 38 :tag "Abbreviations"
38 :group 'editing) 39 :group 'editing)
39 40
40 (defgroup abbrev-mode nil 41 (defcustom abbrev-mode nil
41 "Word abbreviations mode." 42 "Word abbreviations mode."
43 :initialize #'set-default
44 :set #'(lambda (sym val)
45 (global-abbrev-mode (if val 1 0)))
42 :group 'abbrev) 46 :group 'abbrev)
43 47
44 ;jwz: this is preloaded so don't ;;;###autoload 48 (defcustom only-global-abbrevs nil
45 (defcustom only-global-abbrevs nil "\ 49 "*Non-nil means user plans to use global abbrevs only.
46 *Non-nil means user plans to use global abbrevs only.
47 Makes the commands to define mode-specific abbrevs define global ones instead." 50 Makes the commands to define mode-specific abbrevs define global ones instead."
51 :type 'boolean
52 :group 'abbrev)
53
54 (defcustom defining-abbrev-turns-on-abbrev-mode t
55 "*NOn-nil turns on abbrev-mode whenever an abbrev is defined.
56 This occurs only when the user-level commands (e.g. `add-global-abbrev')
57 are used. abbrev-mode is turned on in all buffers or the current-buffer
58 only, depending on whether a global or mode-specific abbrev is defined."
59 ;;#### should turn on in all buffers of current mode in mode-specific abbrev!
48 :type 'boolean 60 :type 'boolean
49 :group 'abbrev) 61 :group 'abbrev)
50 62
51 ;;; XEmacs: the following block of code is not in FSF 63 ;;; XEmacs: the following block of code is not in FSF
52 (defvar abbrev-table-name-list '() 64 (defvar abbrev-table-name-list '()
63 (defun clear-abbrev-table (table) 75 (defun clear-abbrev-table (table)
64 "Undefine all abbrevs in abbrev table TABLE, leaving it empty." 76 "Undefine all abbrevs in abbrev table TABLE, leaving it empty."
65 (fillarray table 0) 77 (fillarray table 0)
66 (setq abbrevs-changed t) 78 (setq abbrevs-changed t)
67 nil) 79 nil)
68
69 80
70 (defun define-abbrev-table (table-name definitions) 81 (defun define-abbrev-table (table-name definitions)
71 "Define TABLE-NAME (a symbol) as an abbrev table name. 82 "Define TABLE-NAME (a symbol) as an abbrev table name.
72 Define abbrevs in it according to DEFINITIONS, which is a list of elements 83 Define abbrevs in it according to DEFINITIONS, which is a list of elements
73 of the form (ABBREVNAME EXPANSION HOOK USECOUNT)." 84 of the form (ABBREVNAME EXPANSION HOOK USECOUNT)."
268 (if (null arg) (not abbrev-mode) 279 (if (null arg) (not abbrev-mode)
269 (> (prefix-numeric-value arg) 0))) 280 (> (prefix-numeric-value arg) 0)))
270 ;; XEmacs change 281 ;; XEmacs change
271 (redraw-modeline)) 282 (redraw-modeline))
272 283
284 ;; XEmacs change
285 (defun global-abbrev-mode (arg)
286 "Toggle abbrev mode in all buffers.
287 With argument ARG, enable abbrev mode globally if ARG is positive, else
288 disable. In abbrev mode, inserting an abbreviation causes it to expand
289 and be replaced by its expansion."
290 (interactive "P")
291 (let ((newval (if (null arg) (not abbrev-mode)
292 (> (prefix-numeric-value arg) 0))))
293 (setq-default abbrev-mode newval)
294 (loop for buf being the buffers do
295 (if (not (eq (symbol-value-in-buffer 'abbrev-mode buf) newval))
296 (with-current-buffer buf
297 (setq abbrev-mode newval)))))
298 (redraw-modeline))
299
273 300
274 (defvar edit-abbrevs-map nil 301 (defvar edit-abbrevs-map nil
275 "Keymap used in edit-abbrevs.") 302 "Keymap used in edit-abbrevs.")
276 (if edit-abbrevs-map 303 (if edit-abbrevs-map
277 nil 304 nil
421 (point) 448 (point)
422 (if (= arg 0) (mark) 449 (if (= arg 0) (mark)
423 (save-excursion (backward-word arg) (point)))))) 450 (save-excursion (backward-word arg) (point))))))
424 451
425 (defun add-mode-abbrev (arg) 452 (defun add-mode-abbrev (arg)
426 "Define mode-specific abbrev for last word(s) before point. 453 "Define mode-specific abbrev for region or last word(s) before point.
427 Argument is how many words before point form the expansion; 454 If region active, use it as the expansion\; otherwise, choose the word
428 or zero means the region is the expansion. 455 before point. A prefix argument specifies the number of words before point
429 A negative argument means to undefine the specified abbrev. 456 that form the expansion; or zero means the text between point and mark is
430 Reads the abbreviation in the minibuffer. 457 the expansion. A negative argument means to undefine the specified abbrev.
458 This command uses the minibuffer to read the abbreviation.
431 459
432 Don't use this function in a Lisp program; use `define-abbrev' instead." 460 Don't use this function in a Lisp program; use `define-abbrev' instead."
433 ;; XEmacs change: 461 ;; XEmacs change:
434 (interactive "P") 462 (interactive "P")
435 (add-abbrev 463 (add-abbrev
436 (if only-global-abbrevs 464 (if only-global-abbrevs
437 global-abbrev-table 465 global-abbrev-table
438 (or local-abbrev-table 466 (or local-abbrev-table
439 (error "No per-mode abbrev table"))) 467 (error "No per-mode abbrev table")))
440 "Mode" arg)) 468 "Mode" arg)
469 (if defining-abbrev-turns-on-abbrev-mode (abbrev-mode 1)))
441 470
442 (defun add-global-abbrev (arg) 471 (defun add-global-abbrev (arg)
443 "Define global (all modes) abbrev for last word(s) before point. 472 "Define global (all modes) abbrev for region or last word(s) before point.
444 The prefix argument specifies the number of words before point that form the 473 If region active, use it as the expansion\; otherwise, choose the word
445 expansion; or zero means the region is the expansion. 474 before point. A prefix argument specifies the number of words before point
446 A negative argument means to undefine the specified abbrev. 475 that form the expansion; or zero means the text between point and mark is
476 the expansion. A negative argument means to undefine the specified abbrev.
447 This command uses the minibuffer to read the abbreviation. 477 This command uses the minibuffer to read the abbreviation.
448 478
449 Don't use this function in a Lisp program; use `define-abbrev' instead." 479 Don't use this function in a Lisp program; use `define-abbrev' instead."
450 ;; XEmacs change: 480 ;; XEmacs change:
451 (interactive "P") 481 (interactive "P")
452 (add-abbrev global-abbrev-table "Global" arg)) 482 (add-abbrev global-abbrev-table "Global" arg)
483 (if defining-abbrev-turns-on-abbrev-mode (global-abbrev-mode 1)))
453 484
454 (defun add-abbrev (table type arg) 485 (defun add-abbrev (table type arg)
455 "Add an abbreviation to abbrev table TABLE. 486 "Add an abbreviation to abbrev table TABLE.
456 TYPE is a string describing in English the kind of abbrev this will be 487 TYPE is a string describing in English the kind of abbrev this will be
457 (typically, \"global\" or \"mode-specific\"); this is used in 488 (typically, \"global\" or \"mode-specific\"); this is used in
490 (inverse-add-abbrev 521 (inverse-add-abbrev
491 (if only-global-abbrevs 522 (if only-global-abbrevs
492 global-abbrev-table 523 global-abbrev-table
493 (or local-abbrev-table 524 (or local-abbrev-table
494 (error "No per-mode abbrev table"))) 525 (error "No per-mode abbrev table")))
495 "Mode" arg)) 526 "Mode" arg)
527 (if defining-abbrev-turns-on-abbrev-mode (abbrev-mode 1)))
496 528
497 (defun inverse-add-global-abbrev (arg) 529 (defun inverse-add-global-abbrev (arg)
498 "Define last word before point as a global (mode-independent) abbrev. 530 "Define last word before point as a global (mode-independent) abbrev.
499 With prefix argument N, defines the Nth word before point. 531 With prefix argument N, defines the Nth word before point.
500 This command uses the minibuffer to read the expansion. 532 This command uses the minibuffer to read the expansion.
501 Expands the abbreviation after defining it." 533 Expands the abbreviation after defining it."
502 (interactive "p") 534 (interactive "p")
503 (inverse-add-abbrev global-abbrev-table "Global" arg)) 535 (inverse-add-abbrev global-abbrev-table "Global" arg)
536 (if defining-abbrev-turns-on-abbrev-mode (global-abbrev-mode 1)))
504 537
505 (defun inverse-add-abbrev (table type arg) 538 (defun inverse-add-abbrev (table type arg)
506 (let (name nameloc exp) 539 (let (name nameloc exp)
507 (save-excursion 540 (save-excursion
508 (backward-word arg) 541 (backward-word arg)