annotate src/cmds.c @ 5353:38e24b8be4ea

Improve the lexical scoping in #'block, #'return-from. lisp/ChangeLog addition: 2011-02-07 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el: * bytecomp.el (byte-compile-initial-macro-environment): Shadow `block', `return-from' here, we implement them differently when byte-compiling. * bytecomp.el (byte-compile-active-blocks): New. * bytecomp.el (byte-compile-block-1): New. * bytecomp.el (byte-compile-return-from-1): New. * bytecomp.el (return-from-1): New. * bytecomp.el (block-1): New. These are two aliases that exist to have their own associated byte-compile functions, which functions implement `block' and `return-from'. * cl-extra.el (cl-macroexpand-all): Fix a bug here when macros in the environment have been compiled. * cl-macs.el (block): * cl-macs.el (return): * cl-macs.el (return-from): Be more careful about lexical scope in these macros. * cl.el: * cl.el ('cl-block-wrapper): Removed. * cl.el ('cl-block-throw): Removed. These aren't needed in code generated by this XEmacs. They shouldn't be needed in code generated by XEmacs 21.4, but if it turns out the packages do need them, we can put them back. 2011-01-30 Mike Sperber <mike@xemacs.org> * font-lock.el (font-lock-fontify-pending-extents): Don't fail if `font-lock-mode' is unset, which can happen in the middle of `revert-buffer'. 2011-01-23 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (delete): * cl-macs.el (delq): * cl-macs.el (remove): * cl-macs.el (remq): Don't use the compiler macro if these functions were given the wrong number of arguments, as happens in lisp-tests.el. * cl-seq.el (remove, remq): Removed. I added these to subr.el, and forgot to remove them from here. 2011-01-22 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-setq, byte-compile-set): Remove kludge allowing keywords' values to be set, all the code that does that is gone. * cl-compat.el (elt-satisfies-test-p): * faces.el (set-face-parent): * faces.el (face-doc-string): * gtk-font-menu.el: * gtk-font-menu.el (gtk-reset-device-font-menus): * msw-font-menu.el: * msw-font-menu.el (mswindows-reset-device-font-menus): * package-get.el (package-get-installedp): * select.el (select-convert-from-image-data): * sound.el: * sound.el (load-sound-file): * x-font-menu.el (x-reset-device-font-menus-core): Don't quote keywords, they're self-quoting, and the win from backward-compatibility is sufficiently small now that the style problem overrides it. 2011-01-22 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (block, return-from): Require that NAME be a symbol in these macros, as always documented in the #'block docstring and as required by Common Lisp. * descr-text.el (unidata-initialize-unihan-database): Correct the use of non-symbols in #'block and #'return-from in this function. 2011-01-15 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (concatenate): Accept more complicated TYPEs in this function, handing the sequences over to #'coerce if we don't understand them here. * cl-macs.el (inline): Don't proclaim #'concatenate as inline, its compiler macro is more useful than doing that. 2011-01-11 Aidan Kehoe <kehoea@parhasard.net> * subr.el (delete, delq, remove, remq): Move #'remove, #'remq here, they don't belong in cl-seq.el; move #'delete, #'delq here from fns.c, implement them in terms of #'delete*, allowing support for sequences generally. * update-elc.el (do-autoload-commands): Use #'delete*, not #'delq here, now the latter's no longer dumped. * cl-macs.el (delete, delq): Add compiler macros transforming #'delete and #'delq to #'delete* calls. 2011-01-10 Aidan Kehoe <kehoea@parhasard.net> * dialog.el (make-dialog-box): Correct a misplaced parenthesis here, thank you Mats Lidell in 87zkr9gqrh.fsf@mail.contactor.se ! 2011-01-02 Aidan Kehoe <kehoea@parhasard.net> * dialog.el (make-dialog-box): * list-mode.el (display-completion-list): These functions used to use cl-parsing-keywords; change them to use defun* instead, fixing the build. (Not sure what led to me not including this change in d1b17a33450b!) 2011-01-02 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (define-star-compiler-macros): Make sure the form has ITEM and LIST specified before attempting to change to calls with explicit tests; necessary for some tests in lisp-tests.el to compile correctly. (stable-union, stable-intersection): Add compiler macros for these functions, in the same way we do for most of the other functions in cl-seq.el. 2011-01-01 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (dolist, dotimes, do-symbols, macrolet) (symbol-macrolet): Define these macros with defmacro* instead of parsing the argument list by hand, for the sake of style and readability; use backquote where appropriate, instead of calling #'list and and friends, for the same reason. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * x-misc.el (device-x-display): Provide this function, documented in the Lispref for years, but not existing previously. Thank you Julian Bradfield, thank you Jeff Mincy. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * cl-seq.el: Move the heavy lifting from this file to C. Dump the cl-parsing-keywords macro, but don't use defun* for the functions we define that do take keywords, dynamic scope lossage makes that not practical. * subr.el (sort, fillarray): Move these aliases here. (map-plist): #'nsublis is now built-in, but at this point #'eql isn't necessarily available as a test; use #'eq. * obsolete.el (cl-delete-duplicates): Make this available for old compiler macros and old code. (memql): Document that this is equivalent to #'member*, and worse. * cl.el (adjoin, subst): Removed. These are in C. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * simple.el (assoc-ignore-case): Remove a duplicate definition of this function (it's already in subr.el). * iso8859-1.el (char-width): On non-Mule, make this function equivalent to that produced by (constantly 1), but preserve its docstring. * subr.el (subst-char-in-string): Define this in terms of #'substitute, #'nsubstitute. (string-width): Define this using #'reduce and #'char-width. (char-width): Give this a simpler definition, it makes far more sense to check for mule at load time and redefine, as we do in iso8859-1.el. (store-substring): Implement this in terms of #'replace, now #'replace is cheap. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * update-elc.el (lisp-files-needed-for-byte-compilation) (lisp-files-needing-early-byte-compilation): cl-macs belongs in the former, not the latter, it is as fundamental as bytecomp.el. 2010-12-30 Aidan Kehoe <kehoea@parhasard.net> * cl.el: Provde the Common Lisp program-error, type-error as error symbols. This doesn't nearly go far enough for anyone using the Common Lisp errors. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (delete-duplicates): If the form has an incorrect number of arguments, don't attempt a compiler macroexpansion. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (cl-safe-expr-p): Forms that start with the symbol lambda are also safe. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (= < > <= >=): For these functions' compiler macros, the optimisation is safe even if the first and the last arguments have side effects, since they're only used the once. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (inline-side-effect-free-compiler-macros): Unroll a loop here at macro-expansion time, so these compiler macros are compiled. Use #'eql instead of #'eq in a couple of places for better style. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (notany, notevery): Avoid some dynamic scope stupidity with local variable names in these functions, when they weren't prefixed with cl-; go into some more detail in the doc strings. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (side-effect-free-fns): #'remove, #'remq are free of side-effects. (side-effect-and-error-free-fns): Drop dot, dot-marker from the list. 2010-11-17 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (coerce): In the argument list, name the first argument OBJECT, not X; the former name was always used in the doc string and is clearer. Handle vector type specifications which include the length of the target sequence, error if there's a mismatch. * cl-macs.el (cl-make-type-test): Handle type specifications starting with the symbol 'eql. 2010-11-14 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (eql): Don't remove the byte-compile property of this symbol. That was necessary to override a bug in bytecomp.el where #'eql was confused with #'eq, which bug we no longer have. If neither expression is constant, don't attempt to handle the expression in this compiler macro, leave it to byte-compile-eql, which produces better code anyway. * bytecomp.el (eq): #'eql is not the function associated with the byte-eq byte code. (byte-compile-eql): Add an explicit compile method for this function, for cases where the cl-macs compiler macro hasn't reduced it to #'eq or #'equal. 2010-10-25 Aidan Kehoe <kehoea@parhasard.net> Add compiler macros and compilation sanity-checking for various functions that take keywords. * byte-optimize.el (side-effect-free-fns): #'symbol-value is side-effect free and not error free. * bytecomp.el (byte-compile-normal-call): Check keyword argument lists for sanity; store information about the positions where keyword arguments start using the new byte-compile-keyword-start property. * cl-macs.el (cl-const-expr-val): Take a new optional argument, cl-not-constant, defaulting to nil, in this function; return it if the expression is not constant. (cl-non-fixnum-number-p): Make this into a separate function, we want to pass it to #'every. (eql): Use it. (define-star-compiler-macros): Use the same code to generate the member*, assoc* and rassoc* compiler macros; special-case some code in #'add-to-list in subr.el. (remove, remq): Add compiler macros for these two functions, in preparation for #'remove being in C. (define-foo-if-compiler-macros): Transform (remove-if-not ...) calls to (remove ... :if-not) at compile time, which will be a real win once the latter is in C. (define-substitute-if-compiler-macros) (define-subst-if-compiler-macros): Similarly for these functions. (delete-duplicates): Change this compiler macro to use #'plists-equal; if we don't have information about the type of SEQUENCE at compile time, don't bother attempting to inline the call, the function will be in C soon enough. (equalp): Remove an old commented-out compiler macro for this, if we want to see it it's in version control. (subst-char-in-string): Transform this to a call to nsubstitute or nsubstitute, if that is appropriate. * cl.el (ldiff): Don't call setf here, this makes for a load-time dependency problem in cl-macs.el 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * term/vt100.el: Refer to XEmacs, not GNU Emacs, in permissions. * term/bg-mouse.el: * term/sup-mouse.el: Put copyright notice in canonical "Copyright DATE AUTHOR" form. Refer to XEmacs, not GNU Emacs, in permissions. * site-load.el: Add permission boilerplate. * mule/canna-leim.el: * alist.el: Refer to XEmacs, not APEL/this program, in permissions. * mule/canna-leim.el: Remove my copyright, I've assigned it to the FSF. 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * gtk.el: * gtk-widget-accessors.el: * gtk-package.el: * gtk-marshal.el: * gtk-compose.el: * gnome.el: Add copyright notice based on internal evidence. 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * easymenu.el: Add reference to COPYING to permission notice. * gutter.el: * gutter-items.el: * menubar-items.el: Fix typo "Xmacs" in permissions notice. 2010-06-14 Stephen J. Turnbull <stephen@xemacs.org> * auto-save.el: * font.el: * fontconfig.el: * mule/kinsoku.el: Add "part of XEmacs" text to permission notice. 2010-10-14 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (side-effect-free-fns): * cl-macs.el (remf, getf): * cl-extra.el (tailp, cl-set-getf, cl-do-remf): * cl.el (ldiff, endp): Tighten up Common Lisp compatibility for #'ldiff, #'endp, #'tailp; add circularity checking for the first two. #'cl-set-getf and #'cl-do-remf were Lisp implementations of #'plist-put and #'plist-remprop; change the names to aliases, changes the macros that use them to using #'plist-put and #'plist-remprop directly. 2010-10-12 Aidan Kehoe <kehoea@parhasard.net> * abbrev.el (fundamental-mode-abbrev-table, global-abbrev-table): Create both these abbrev tables using the usual #'define-abbrev-table calls, rather than attempting to special-case them. * cl-extra.el: Force cl-macs to be loaded here, if cl-extra.el is being loaded interpreted. Previously other, later files would redundantly call (load "cl-macs") when interpreted, it's more reasonable to do it here, once. * cmdloop.el (read-quoted-char-radix): Use defcustom here, we don't have any dump-order dependencies that would prevent that. * custom.el (eval-when-compile): Don't load cl-macs when interpreted or when byte-compiling, rely on cl-extra.el in the former case and the appropriate entry in bytecomp-load-hook in the latter. Get rid of custom-declare-variable-list, we have no dump-time dependencies that would require it. * faces.el (eval-when-compile): Don't load cl-macs when interpreted or when byte-compiling. * packages.el: Remove some inaccurate comments. * post-gc.el (cleanup-simple-finalizers): Use #'delete-if-not here, now the order of preloaded-file-list has been changed to make it available. * subr.el (custom-declare-variable-list): Remove. No need for it. Also remove a stub define-abbrev-table from this file, given the current order of preloaded-file-list there's no need for it. 2010-10-10 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-constp) Forms quoted with FUNCTION are also constant. (byte-compile-initial-macro-environment): In #'the, if FORM is constant and does not match TYPE, warn at byte-compile time. 2010-10-10 Aidan Kehoe <kehoea@parhasard.net> * backquote.el (bq-vector-contents, bq-list*): Remove; the former is equivalent to (append VECTOR nil), the latter to (list* ...). (bq-process-2): Use (append VECTOR nil) instead of using #'bq-vector-contents to convert to a list. (bq-process-1): Now we use list* instead of bq-list * subr.el (list*): Moved from cl.el, since it is now required to be available the first time a backquoted form is encountered. * cl.el (list*): Move to subr.el. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * test-harness.el (Check-Message): Add an omitted comma here, thank you the buildbot. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * hash-table.el (hash-table-key-list, hash-table-value-list) (hash-table-key-value-alist, hash-table-key-value-plist): Remove some useless #'nreverse calls in these files; our hash tables have no order, it's not helpful to pretend they do. * behavior.el (read-behavior): Do the same in this file, in some code evidently copied from hash-table.el. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * info.el (Info-insert-dir): * format.el (format-deannotate-region): * files.el (cd, save-buffers-kill-emacs): Use #'some, #'every and related functions for applying boolean operations to lists, instead of rolling our own ones that cons and don't short-circuit. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-initial-macro-environment): * cl-macs.el (the): Rephrase the docstring, make its implementation when compiling files a little nicer. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * descr-text.el (unidata-initialize-unicodedata-database) (unidata-initialize-unihan-database, describe-char-unicode-data) (describe-char-unicode-data): Wrap calls to the database functions with (with-fboundp ...), avoiding byte compile warnings on builds without support for the database functions. (describe-char): (reduce #'max ...), not (apply #'max ...), no need to cons needlessly. (describe-char): Remove a redundant lambda wrapping #'extent-properties. (describe-char-unicode-data): Call #'nsubst when replacing "" with nil in the result of #'split-string, instead of consing inside mapcar. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * x-faces.el (x-available-font-sizes): * specifier.el (let-specifier): * package-ui.el (pui-add-required-packages): * msw-faces.el (mswindows-available-font-sizes): * modeline.el (modeline-minor-mode-menu): * minibuf.el (minibuf-directory-files): Replace the O2N (delq nil (mapcar (lambda (W) (and X Y)) Z)) with the ON (mapcan (lambda (W) (and X (list Y))) Z) in these files. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (= < > <= >=): When these functions are handed more than two arguments, and those arguments have no side effects, transform to a series of two argument calls, avoiding funcall in the byte-compiled code. * mule/mule-cmds.el (finish-set-language-environment): Take advantage of this change in a function called 256 times at startup. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-function-form, byte-compile-quote) (byte-compile-quote-form): Warn at compile time, and error at runtime, if a (quote ...) or a (function ...) form attempts to quote more than one object. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (byte-optimize-apply): Transform (apply 'nconc (mapcar ...)) to (mapcan ...); warn about use of the first idiom. * update-elc.el (do-autoload-commands): * packages.el (packages-find-package-library-path): * frame.el (frame-list): * extents.el (extent-descendants): * etags.el (buffer-tag-table-files): * dumped-lisp.el (preloaded-file-list): * device.el (device-list): * bytecomp-runtime.el (proclaim-inline, proclaim-notinline) Use #'mapcan, not (apply #'nconc (mapcar ...) in all these files. * bytecomp-runtime.el (eval-when-compile, eval-and-compile): In passing, mention that these macros also evaluate the body when interpreted. tests/ChangeLog addition: 2011-02-07 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: Test lexical scope for `block', `return-from'; add a Known-Bug-Expect-Failure for a contorted example that fails when byte-compiled.
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 07 Feb 2011 12:01:24 +0000
parents c096d8051f89
children 8d29f1c4bb98
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Simple built-in editing commands.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
3 Copyright (C) 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 /* Synched up with: Mule 2.0, FSF 19.30. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 #include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 #include "lisp.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 #include "commands.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 #include "buffer.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
28 #include "extents.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 #include "syntax.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 #include "insdel.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 Lisp_Object Qkill_forward_chars;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 Lisp_Object Qself_insert_command;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 Lisp_Object Qno_self_insert;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 Lisp_Object Vblink_paren_function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 /* A possible value for a buffer's overwrite-mode variable. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 Lisp_Object Qoverwrite_mode_binary;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 /* Non-nil means put this face on the next self-inserting character. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 Lisp_Object Vself_insert_face;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 /* This is the command that set up Vself_insert_face. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 Lisp_Object Vself_insert_face_command;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
46
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
47 /* A char-table for characters which may invoke auto-filling. */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
48 Lisp_Object Vauto_fill_chars;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 DEFUN ("forward-char", Fforward_char, 0, 2, "_p", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
51 Move point right COUNT characters (left if COUNT is negative).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 On attempt to pass end of buffer, stop and signal `end-of-buffer'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 On attempt to pass beginning of buffer, stop and signal `beginning-of-buffer'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 On reaching end of buffer, stop and signal error.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
55
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
56 The characters that are moved over may be added to the current selection
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
57 \(i.e. active region) if the Shift key is held down, a motion key is used
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
58 to invoke this command, and `shifted-motion-keys-select-region' is t; see
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
59 the documentation for this variable for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
61 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 struct buffer *buf = decode_buffer (buffer, 1);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
64 EMACS_INT n;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
66 if (NILP (count))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
67 n = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
70 CHECK_INT (count);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
71 n = XINT (count);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
74 /* This used to just set point to point + XINT (count), and then check
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 to see if it was within boundaries. But now that SET_PT can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 potentially do a lot of stuff (calling entering and exiting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 hooks, etcetera), that's not a good approach. So we validate the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 proposed position, then set point. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 {
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
80 Charbpos new_point = BUF_PT (buf) + n;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 if (new_point < BUF_BEGV (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 BUF_SET_PT (buf, BUF_BEGV (buf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 Fsignal (Qbeginning_of_buffer, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 if (new_point > BUF_ZV (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 BUF_SET_PT (buf, BUF_ZV (buf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 Fsignal (Qend_of_buffer, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 BUF_SET_PT (buf, new_point);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 DEFUN ("backward-char", Fbackward_char, 0, 2, "_p", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
102 Move point left COUNT characters (right if COUNT is negative).
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 On attempt to pass end of buffer, stop and signal `end-of-buffer'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 On attempt to pass beginning of buffer, stop and signal `beginning-of-buffer'.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
105
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
106 The characters that are moved over may be added to the current selection
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
107 \(i.e. active region) if the Shift key is held down, a motion key is used
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
108 to invoke this command, and `shifted-motion-keys-select-region' is t; see
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
109 the documentation for this variable for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
111 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
113 if (NILP (count))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
114 count = make_int (-1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
117 CHECK_INT (count);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
118 count = make_int (- XINT (count));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 }
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
120 return Fforward_char (count, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 DEFUN ("forward-line", Fforward_line, 0, 2, "_p", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
124 Move COUNT lines forward (backward if COUNT is negative).
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
125 Precisely, if point is on line I, move to the start of line I + COUNT.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 If there isn't room, go as far as possible (no error).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 Returns the count of lines left to move. If moving forward,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
128 that is COUNT - number of lines moved; if backward, COUNT + number moved.
3577
91950589598c [xemacs-hg @ 2006-08-29 14:10:51 by stephent]
stephent
parents: 2862
diff changeset
129 \(Note that if COUNT is negative, the return will be non-positive.)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
130 With positive COUNT, a non-empty line at the end counts as one line
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 successfully moved (for the return value).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 If BUFFER is nil, the current buffer is assumed.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
133
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
134 The characters that are moved over may be added to the current selection
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
135 \(i.e. active region) if the Shift key is held down, a motion key is used
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
136 to invoke this command, and `shifted-motion-keys-select-region' is t; see
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
137 the documentation for this variable for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
139 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 struct buffer *buf = decode_buffer (buffer, 1);
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
142 Charbpos pos2 = BUF_PT (buf);
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
143 Charbpos pos;
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
144 EMACS_INT n, shortage, negp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
146 if (NILP (count))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
147 n = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
150 CHECK_INT (count);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
151 n = XINT (count);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
154 negp = n <= 0;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
155 pos = scan_buffer (buf, '\n', pos2, 0, n - negp, &shortage, 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 if (shortage > 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 && (negp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 || (BUF_ZV (buf) > BUF_BEGV (buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 && pos != pos2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 && BUF_FETCH_CHAR (buf, pos - 1) != '\n')))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 shortage--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 BUF_SET_PT (buf, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 return make_int (negp ? - shortage : shortage);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 DEFUN ("point-at-bol", Fpoint_at_bol, 0, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 Return the character position of the first character on the current line.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
168 With argument COUNT not nil or 1, move forward COUNT - 1 lines first.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 If scan reaches end of buffer, return that position.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 This function does not move point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
172 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 struct buffer *b = decode_buffer (buffer, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 REGISTER int orig, end;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
793
e38acbeb1cae [xemacs-hg @ 2002-03-29 04:46:17 by ben]
ben
parents: 665
diff changeset
177 buffer = wrap_buffer (b);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
178 if (NILP (count))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
179 count = make_int (0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
182 CHECK_INT (count);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
183 count = make_int (XINT (count) - 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 orig = BUF_PT (b);
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
187 Fforward_line (count, buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 end = BUF_PT (b);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 BUF_SET_PT (b, orig);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 return make_int (end);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 DEFUN ("beginning-of-line", Fbeginning_of_line, 0, 2, "_p", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 Move point to beginning of current line.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
196 With argument COUNT not nil or 1, move forward COUNT - 1 lines first.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 If scan reaches end of buffer, stop there without error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 If BUFFER is nil, the current buffer is assumed.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
199
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
200 The characters that are moved over may be added to the current selection
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
201 \(i.e. active region) if the Shift key is held down, a motion key is used
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
202 to invoke this command, and `shifted-motion-keys-select-region' is t; see
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
203 the documentation for this variable for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
205 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 struct buffer *b = decode_buffer (buffer, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
209 BUF_SET_PT (b, XINT (Fpoint_at_bol (count, buffer)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 DEFUN ("point-at-eol", Fpoint_at_eol, 0, 2, 0, /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 Return the character position of the last character on the current line.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
215 With argument COUNT not nil or 1, move forward COUNT - 1 lines first.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 If scan reaches end of buffer, return that position.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 This function does not move point.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
219 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 struct buffer *buf = decode_buffer (buffer, 1);
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
222 EMACS_INT n;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
224 if (NILP (count))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
225 n = 1;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
228 CHECK_INT (count);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
229 n = XINT (count);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 return make_int (find_before_next_newline (buf, BUF_PT (buf), 0,
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
233 n - (n <= 0)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 DEFUN ("end-of-line", Fend_of_line, 0, 2, "_p", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 Move point to end of current line.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
238 With argument COUNT not nil or 1, move forward COUNT - 1 lines first.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 If scan reaches end of buffer, stop there without error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 If BUFFER is nil, the current buffer is assumed.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
241
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
242 The characters that are moved over may be added to the current selection
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
243 \(i.e. active region) if the Shift key is held down, a motion key is used
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
244 to invoke this command, and `shifted-motion-keys-select-region' is t; see
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 446
diff changeset
245 the documentation for this variable for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
247 (count, buffer))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 struct buffer *b = decode_buffer (buffer, 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
251 BUF_SET_PT (b, XINT (Fpoint_at_eol (count, buffer)));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
255 DEFUN ("delete-char", Fdelete_char, 0, 2, "*p\nP", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
256 Delete the following COUNT characters (previous, with negative COUNT).
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
257 Optional second arg KILLP non-nil means kill instead (save in kill ring).
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
258 Interactively, COUNT is the prefix arg, and KILLP is set if
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
259 COUNT was explicitly specified.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
261 (count, killp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 /* This function can GC */
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 563
diff changeset
264 Charbpos pos;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 struct buffer *buf = current_buffer;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
266 EMACS_INT n;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
268 if (NILP (count))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
269 n = 1;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
270 else
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
271 {
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
272 CHECK_INT (count);
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
273 n = XINT (count);
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
274 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
276 pos = BUF_PT (buf) + n;
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
277 if (NILP (killp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
279 if (n < 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 if (pos < BUF_BEGV (buf))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
282 signal_error (Qbeginning_of_buffer, 0, Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 buffer_delete_range (buf, pos, BUF_PT (buf), 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 if (pos > BUF_ZV (buf))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
289 signal_error (Qend_of_buffer, 0, Qunbound);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 buffer_delete_range (buf, BUF_PT (buf), pos, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 {
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
296 call1 (Qkill_forward_chars, count);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
301 DEFUN ("delete-backward-char", Fdelete_backward_char, 0, 2, "*p\nP", /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
302 Delete the previous COUNT characters (following, with negative COUNT).
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
303 Optional second arg KILLP non-nil means kill instead (save in kill ring).
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
304 Interactively, COUNT is the prefix arg, and KILLP is set if
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
305 COUNT was explicitly specified.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
307 (count, killp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 /* This function can GC */
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
310 EMACS_INT n;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
311
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
312 if (NILP (count))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
313 n = 1;
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
314 else
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
315 {
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
316 CHECK_INT (count);
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
317 n = XINT (count);
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
318 }
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
319
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
320 return Fdelete_char (make_int (- n), killp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
323 static void internal_self_insert (Ichar ch, int noautofill);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 DEFUN ("self-insert-command", Fself_insert_command, 1, 1, "*p", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 Insert the character you type.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 Whichever character you type to run this command is inserted.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
328 If a prefix arg COUNT is specified, the character is inserted COUNT times.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
330 (count))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 /* This function can GC */
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
333 Ichar ch;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 Lisp_Object c;
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
335 EMACS_INT n;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336
5307
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3577
diff changeset
337 /* Can't insert more than most-positive-fixnum characters, the buffer
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3577
diff changeset
338 won't hold that many. */
c096d8051f89 Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents: 3577
diff changeset
339 check_integer_range (count, Qzero, make_int (EMACS_INT_MAX));
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
340 n = XINT (count);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 if (CHAR_OR_CHAR_INTP (Vlast_command_char))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 c = Vlast_command_char;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 else
2862
b95fe16005fd [xemacs-hg @ 2005-07-17 20:08:40 by aidan]
aidan
parents: 2828
diff changeset
345 c = Fevent_to_character (Vlast_command_event, Qnil, Qnil, Qnil);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 if (NILP (c))
2828
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 872
diff changeset
348 invalid_operation (
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 872
diff changeset
349 "Last typed key has no character equivalent (that we know of)",
a25c824ed558 [xemacs-hg @ 2005-06-26 18:04:49 by aidan]
aidan
parents: 872
diff changeset
350 Fcopy_event (Vlast_command_event, Qnil));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 CHECK_CHAR_COERCE_INT (c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 ch = XCHAR (c);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
356 while (n--)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
357 internal_self_insert (ch, (n != 0));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 /* Insert character C1. If NOAUTOFILL is nonzero, don't do autofill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 even if it is enabled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 FSF:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 If this insertion is suitable for direct output (completely simple),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 return 0. A value of 1 indicates this *might* not have been simple.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 A value of 2 means this did things that call for an undo boundary. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 static void
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
372 internal_self_insert (Ichar c1, int noautofill)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 /* This function can GC */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 /* int hairy = 0; -- unused */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 REGISTER enum syntaxcode synt;
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 826
diff changeset
377 REGISTER Ichar c2;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 Lisp_Object overwrite;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
379 Lisp_Object syntax_table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 struct buffer *buf = current_buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 int tab_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 overwrite = buf->overwrite_mode;
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
384 syntax_table = buf->mirror_syntax_table;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 #if 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 /* No, this is very bad, it makes undo *always* undo a character at a time
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 instead of grouping consecutive self-inserts together. Nasty nasty.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 || !NILP (Vbefore_change_function) || !NILP (Vafter_change_function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 hairy = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 if (!NILP (overwrite)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 && BUF_PT (buf) < BUF_ZV (buf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 && (EQ (overwrite, Qoverwrite_mode_binary)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 || (c1 != '\n' && BUF_FETCH_CHAR (buf, BUF_PT (buf)) != '\n'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 && (EQ (overwrite, Qoverwrite_mode_binary)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 || BUF_FETCH_CHAR (buf, BUF_PT (buf)) != '\t'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 || ((tab_width = XINT (buf->tab_width), tab_width <= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 || tab_width > 20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 || !((current_column (buf) + 1) % tab_width))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 buffer_delete_range (buf, BUF_PT (buf), BUF_PT (buf) + 1, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 /* hairy = 2; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 if (!NILP (buf->abbrev_mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 && !WORD_SYNTAX_P (syntax_table, c1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 && NILP (buf->read_only)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 && BUF_PT (buf) > BUF_BEGV (buf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 c2 = BUF_FETCH_CHAR (buf, BUF_PT (buf) - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 if (WORD_SYNTAX_P (syntax_table, c2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 #if 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 Fexpand_abbrev ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 #else /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 Lisp_Object sym = Fexpand_abbrev ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 /* I think this is too bogus to add. The function should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 have a way of examining the character to be inserted, so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 it can decide whether to insert it or not. We should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 design it better than that. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 /* Here FSFmacs remembers MODIFF, compares it after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 Fexpand_abbrev() finishes, and updates HAIRY. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 /* NOTE: we cannot simply check for Vlast_abbrev, because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 Fexpand_abbrev() can bail out before setting it to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 anything meaningful, leaving us stuck with an old value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 Thus Fexpand_abbrev() was extended to return the actual
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 abbrev symbol. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 if (!NILP (sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 && !NILP (symbol_function (XSYMBOL (sym)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 && SYMBOLP (symbol_function (XSYMBOL (sym))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 Lisp_Object prop = Fget (symbol_function (XSYMBOL (sym)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 Qno_self_insert, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 if (!NILP (prop))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 #endif /* FSFmacs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
448 if ((CHAR_TABLEP (Vauto_fill_chars)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 793
diff changeset
449 ? !NILP (get_char_table (c1, Vauto_fill_chars))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
450 : (c1 == ' ' || c1 == '\n'))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 && !noautofill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 && !NILP (buf->auto_fill_function))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 buffer_insert_emacs_char (buf, c1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 if (c1 == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 /* After inserting a newline, move to previous line and fill */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 /* that. Must have the newline in place already so filling and */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 /* justification, if any, know where the end is going to be. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 BUF_SET_PT (buf, BUF_PT (buf) - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 call0 (buf->auto_fill_function);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 if (c1 == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 BUF_SET_PT (buf, BUF_PT (buf) + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 /* hairy = 2; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 buffer_insert_emacs_char (buf, c1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 /* If previous command specified a face to use, use it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 if (!NILP (Vself_insert_face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 && EQ (Vlast_command, Vself_insert_face_command))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 Lisp_Object before = make_int (BUF_PT (buf) - 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 Lisp_Object after = make_int (BUF_PT (buf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 Fput_text_property (before, after, Qface, Vself_insert_face, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 Fput_text_property (before, after, Qstart_open, Qt, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 Fput_text_property (before, after, Qend_open, Qnil, Qnil);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 /* #### FSFmacs properties are normally closed ("sticky") on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 end but not the beginning. It's the opposite for us. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 Vself_insert_face = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 synt = SYNTAX (syntax_table, c1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 if ((synt == Sclose || synt == Smath)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 && !NILP (Vblink_paren_function) && INTERACTIVE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 && !noautofill)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 call0 (Vblink_paren_function);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 /* hairy = 2; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 /* return hairy; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 /* (this comes from Mule but is a generally good idea) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 DEFUN ("self-insert-internal", Fself_insert_internal, 1, 1, 0, /*
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
496 Invoke `self-insert-command' as if CHARACTER is entered from keyboard.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
498 (character))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 /* This function can GC */
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
501 CHECK_CHAR_COERCE_INT (character);
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
502 internal_self_insert (XCHAR (character), 0);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 /* module initialization */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 syms_of_cmds (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
511 DEFSYMBOL (Qkill_forward_chars);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
512 DEFSYMBOL (Qself_insert_command);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
513 DEFSYMBOL (Qoverwrite_mode_binary);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
514 DEFSYMBOL (Qno_self_insert);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 DEFSUBR (Fforward_char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 DEFSUBR (Fbackward_char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 DEFSUBR (Fforward_line);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 DEFSUBR (Fbeginning_of_line);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 DEFSUBR (Fend_of_line);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 DEFSUBR (Fpoint_at_bol);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 DEFSUBR (Fpoint_at_eol);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 DEFSUBR (Fdelete_char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 DEFSUBR (Fdelete_backward_char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 DEFSUBR (Fself_insert_command);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 DEFSUBR (Fself_insert_internal);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 vars_of_cmds (void)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 DEFVAR_LISP ("self-insert-face", &Vself_insert_face /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 If non-nil, set the face of the next self-inserting character to this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 See also `self-insert-face-command'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 Vself_insert_face = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 DEFVAR_LISP ("self-insert-face-command", &Vself_insert_face_command /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 This is the command that set up `self-insert-face'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 If `last-command' does not equal this value, we ignore `self-insert-face'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 Vself_insert_face_command = Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 DEFVAR_LISP ("blink-paren-function", &Vblink_paren_function /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 Function called, if non-nil, whenever a close parenthesis is inserted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 More precisely, a char with closeparen syntax is self-inserted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 */ );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 Vblink_paren_function = Qnil;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
552
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
553 DEFVAR_LISP ("auto-fill-chars", &Vauto_fill_chars /*
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
554 A char-table for characters which invoke auto-filling.
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
555 Such characters have value t in this table.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
556 */);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
557 Vauto_fill_chars = Fmake_char_table (Qgeneric);
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
558 XCHAR_TABLE (Vauto_fill_chars)->ascii[' '] = Qt;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
559 XCHAR_TABLE (Vauto_fill_chars)->ascii['\n'] = Qt;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 }