From: Eshel Yaron Date: Mon, 14 Apr 2025 15:45:52 +0000 (+0200) Subject: startup.el: Various cleanups, move abbrev to Lisp. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e54112f1573a5710ea996f359d0661bdae7d7f3b;p=emacs.git startup.el: Various cleanups, move abbrev to Lisp. --- diff --git a/lisp/abbrev.el b/lisp/abbrev.el index d470d2aa2f4..8f8ba780b3a 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -53,16 +53,22 @@ define global abbrevs instead." :group 'abbrev-mode :group 'convenience) +(defvar-local local-abbrev-table nil + "Local (mode-specific) abbrev table of current buffer.") + +(defvar abbrevs--loaded nil) + (define-minor-mode abbrev-mode "Toggle Abbrev mode in the current buffer. In Abbrev mode, inserting an abbreviation causes it to expand and be replaced by its expansion." - ;; It's defined in C, this stops the 'define-minor-mode' macro from - ;; defining it again. - :variable abbrev-mode) - -(put 'abbrev-mode 'safe-local-variable 'booleanp) + :lighter " Abbrev" + (if abbrev-mode + (progn + (add-hook 'post-self-insert-hook #'abbrev-post-self-insert nil t) + (and (not abbrevs--loaded) (read-abbrev-file))) + (remove-hook 'post-self-insert-hook #'abbrev-post-self-insert t))) (define-obsolete-variable-alias 'edit-abbrevs-map @@ -215,26 +221,18 @@ defined by the current buffer contents." (forward-line 1)) (define-abbrev-table table abbrevs))))) -(defun read-abbrev-file (&optional file quietly) +(defun read-abbrev-file (&optional file) "Read abbrev definitions from file written with `write-abbrev-file'. Optional argument FILE is the name of the file to read; -it defaults to the value of `abbrev-file-name'. -Optional second argument QUIETLY non-nil means don't display a message -about loading the abbrevs." +it defaults to the value of `abbrev-file-name'." (interactive (list (read-file-name (format-prompt "Read abbrev file" abbrev-file-name) nil abbrev-file-name t))) - (load (or file abbrev-file-name) nil quietly) - (setq abbrevs-changed nil)) - -(defun quietly-read-abbrev-file (&optional file) - "Quietly read abbrev definitions from file written with `write-abbrev-file'. -Optional argument FILE is the name of the file to read; -it defaults to the value of `abbrev-file-name'. -Do not display any messages about loading the abbrevs." - ;(interactive "fRead abbrev file: ") - (read-abbrev-file file t)) + (let ((file (or file abbrev-file-name))) + (when (file-readable-p abbrev-file-name) + (load (or file abbrev-file-name) nil t))) + (setq abbrevs-changed nil abbrevs--loaded t)) (defun write-abbrev-file (&optional file verbose) "Write all user-level abbrev definitions to a file of Lisp code. @@ -880,19 +878,7 @@ see `define-abbrev' for details." (goto-char end)))))) ;; Now point is at the end of the expansion and the beginning is ;; in last-abbrev-location. - (when (symbol-function abbrev) - (let* ((hook (symbol-function abbrev)) - (expanded - ;; If the abbrev has a hook function, run it. - (funcall hook))) - ;; In addition, if the hook function is a symbol with - ;; a non-nil `no-self-insert' property, let the value it - ;; returned specify whether we consider that an expansion took - ;; place. If it returns nil, no expansion has been done. - (if (and (symbolp hook) - (null expanded) - (get hook 'no-self-insert)) - (setq value nil)))) + (when-let ((hook (symbol-function abbrev))) (funcall hook)) value)) (defvar abbrev-expand-functions nil @@ -1056,6 +1042,13 @@ be the abbrev symbol if expansion occurred, else nil.)" (if abbrev-suggest (abbrev--suggest-maybe-suggest)))) +(defun abbrev-post-self-insert () + (and (characterp last-command-event) + (not (eq (char-syntax last-command-event) ?w)) + (not buffer-read-only) + (eq (char-syntax (char-before (1- (point)))) ?w) + (expand-abbrev))) + (defun abbrev--default-expand () "Default function to use for `abbrev-expand-function'. This also respects the obsolete wrapper hook `abbrev-expand-functions'. diff --git a/lisp/font-core.el b/lisp/font-core.el index 04a2056d9f7..b995646e5a6 100644 --- a/lisp/font-core.el +++ b/lisp/font-core.el @@ -271,7 +271,7 @@ means that Font Lock mode is turned on for buffers in C and C++ modes only." ;; What was this :extra-args thingy for? --Stef ;; :extra-args (dummy) :initialize 'custom-initialize-delay - :init-value (not (or noninteractive emacs-basic-display)) + :init-value (not noninteractive) :group 'font-lock :version "22.1") diff --git a/lisp/frame.el b/lisp/frame.el index 39bf80fbc77..b38b41af543 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -3179,9 +3179,7 @@ See also `blink-cursor-interval' and `blink-cursor-delay'. This command is effective only on graphical frames. On text-only terminals, cursor blinking is controlled by the terminal." - :init-value (not (or noninteractive - no-blinking-cursor - (eq system-type 'ms-dos))) + :init-value (not (or noninteractive (eq system-type 'ms-dos))) :initialize #'custom-initialize-delay :group 'cursor :global t diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 9e20e33ce88..552b5576190 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el @@ -295,9 +295,7 @@ Check it when `gud-running' is t") gdb-active-process))))] ["Refresh" gud-refresh] ["Show GUD tooltips" gud-tooltip-mode - :enable (and (not emacs-basic-display) - (display-graphic-p) - (fboundp 'x-show-tip)) + :enable (and (display-graphic-p) (fboundp 'x-show-tip)) :visible (memq gud-minor-mode '(gdbmi lldb guiler dbx sdb xdb pdb)) :button (:toggle . gud-tooltip-mode)] diff --git a/lisp/skeleton.el b/lisp/skeleton.el index b77009195dd..9f3b8fa13fc 100644 --- a/lisp/skeleton.el +++ b/lisp/skeleton.el @@ -113,16 +113,12 @@ DOCUMENTATION is that of the command. SKELETON is as defined under `skeleton-insert'." (declare (doc-string 2) (debug (&define name stringp skeleton-edebug-spec)) (indent defun)) - `(progn - ;; Tell self-insert-command that this function, if called by an - ;; abbrev, should cause the self-insert to be skipped. - (put ',command 'no-self-insert t) - (defun ,command (&optional str arg) - ,(concat documentation - (if (string-match "\n\\'" documentation) - "" "\n") - "\n" - "This is a skeleton command (see `skeleton-insert'). + `(defun ,command (&optional str arg) + ,(concat documentation + (if (string-match "\n\\'" documentation) + "" "\n") + "\n" + "This is a skeleton command (see `skeleton-insert'). Normally the skeleton text is inserted at point, with nothing \"inside\". If there is a highlighted region, the skeleton text is wrapped around the region text. @@ -131,9 +127,9 @@ A prefix argument ARG says to wrap the skeleton around the next ARG words. A prefix argument of -1 says to wrap around region, even if not highlighted. A prefix argument of zero says to wrap around zero words---that is, nothing. This is a way of overriding the use of a highlighted region.") - (interactive "*P\nP") - (atomic-change-group - (skeleton-proxy-new ',skeleton str arg))))) + (interactive "*P\nP") + (atomic-change-group + (skeleton-proxy-new ',skeleton str arg)))) ;;;###autoload (defun skeleton-proxy-new (skeleton &optional str arg) @@ -162,7 +158,6 @@ of `str' whereas the skeleton's interactor is then ignored." (if (stringp str) str)) ;; Return non-nil to tell expand-abbrev that expansion has happened. - ;; Otherwise the no-self-insert is ignored. t) ;;;###autoload diff --git a/lisp/startup.el b/lisp/startup.el index c472f8a2f63..86443339ce5 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -56,8 +56,6 @@ string or function value that this variable has." (const :tag "Startup screen" nil) (directory :tag "Directory" :value "~/") (file :tag "File" :value "~/.emacs") - ;; Note sure about hard-coding this as an option... - (const :tag "Remember Mode notes buffer" remember-notes) (function :tag "Function") (const :tag "Lisp scratch buffer" t)) :version "23.1") @@ -296,21 +294,9 @@ these functions will invoke the debugger.") (defvar emacs-startup-hook nil "Normal hook run after loading init files and handling the command line.") -(defvar term-setup-hook nil - "Normal hook run immediately after `emacs-startup-hook'. -In new code, there is no reason to use this instead of `emacs-startup-hook'. -If you want to execute terminal-specific Lisp code, for example -to override the definitions made by the terminal-specific file, -see `tty-setup-hook'.") - -(make-obsolete-variable 'term-setup-hook - "use either `emacs-startup-hook' or \ -`tty-setup-hook' instead." "24.4") - (defvar inhibit-startup-hooks nil "Non-nil means don't run some startup hooks, because we already did. -Currently this applies to: `emacs-startup-hook', `term-setup-hook', -and `window-setup-hook'.") +Currently this applies to: `emacs-startup-hook' and `window-setup-hook'.") (defvar early-init-file nil "File name, including directory, of user's early init file. @@ -318,14 +304,6 @@ See `user-init-file'. The only difference is that `early-init-file' is not set during the course of evaluating the early init file.") -(defvar keyboard-type nil - "The brand of keyboard you are using. -This variable is used to define the proper function and keypad -keys for use under X. It is used in a fashion analogous to the -environment variable TERM.") -(make-obsolete-variable 'keyboard-type nil "28.1") -(internal-make-var-non-special 'keyboard-type) - (defvar window-setup-hook nil "Normal hook run after loading init files and handling the command line. This is very similar to `emacs-startup-hook'. The only difference @@ -416,8 +394,6 @@ from being initialized." string) :group 'auto-save) -(defvar emacs-basic-display nil) - (defvar init-file-debug nil) (defvar init-file-had-error nil @@ -425,8 +401,6 @@ from being initialized." (defvar normal-top-level-add-subdirs-inode-list nil) -(defvar no-blinking-cursor nil) - (defcustom tutorial-directory (file-name-as-directory (expand-file-name "tutorials" data-directory)) "Directory containing the Emacs TUTORIAL files." @@ -802,7 +776,7 @@ It is the default value of the variable `top-level'." (emacs-pid) (system-name)))))))) (unless inhibit-startup-hooks - (run-hooks 'emacs-startup-hook 'term-setup-hook)) + (run-hooks 'emacs-startup-hook)) ;; Don't do this if we failed to create the initial frame, ;; for instance due to a dense colormap. @@ -1144,503 +1118,481 @@ the `--debug-init' option to view a complete error backtrace." (defun command-line () "A subroutine of `normal-top-level'. Amongst another things, it parses the command-line arguments." - (let (xdg-dir startup-init-directory) - (setq before-init-time (current-time) - after-init-time nil - command-line-default-directory default-directory) - - ;; Force recomputation, in case it was computed during the dump. - (setq abbreviated-home-dir nil) - - ;; See if we should import version-control from the environment variable. - (let ((vc (getenv "VERSION_CONTROL"))) - (cond ((eq vc nil)) ;don't do anything if not set - ((member vc '("t" "numbered")) - (setq version-control t)) - ((member vc '("nil" "existing")) - (setq version-control nil)) - ((member vc '("never" "simple")) - (setq version-control 'never)))) - - ;;! This has been commented out; I currently find the behavior when - ;;! split-window-keep-point is nil disturbing, but if I can get used - ;;! to it, then it would be better to eliminate the option. - ;;! ;; Choose a good default value for split-window-keep-point. - ;;! (setq split-window-keep-point (> baud-rate 2400)) - - ;; Convert preloaded file names in load-history to absolute. - (let ((simple-file-name - ;; Look for simple.el or simple.elc and use their directory - ;; as the place where all Lisp files live. - (locate-file "simple" load-path (get-load-suffixes)))) - ;; Don't abort if simple.el cannot be found, but print a warning. - ;; Although in most usage we are going to cryptically abort a moment - ;; later anyway, due to missing required bidi data files (eg bug#13430). - (if (null simple-file-name) - (let ((standard-output 'external-debugging-output) - (lispdir (expand-file-name "../lisp" data-directory))) - (princ "Warning: Could not find simple.el or simple.elc") - (terpri) - (when (getenv "EMACSLOADPATH") - (princ "The EMACSLOADPATH environment variable is set, \ + (let (xdg-dir startup-init-directory) + (setq before-init-time (current-time) + after-init-time nil + command-line-default-directory default-directory) + + ;; Force recomputation, in case it was computed during the dump. + (setq abbreviated-home-dir nil) + + ;; See if we should import version-control from the environment variable. + (let ((vc (getenv "VERSION_CONTROL"))) + (cond ((eq vc nil)) ;don't do anything if not set + ((member vc '("t" "numbered")) + (setq version-control t)) + ((member vc '("nil" "existing")) + (setq version-control nil)) + ((member vc '("never" "simple")) + (setq version-control 'never)))) + + ;; Convert preloaded file names in load-history to absolute. + (let ((simple-file-name + ;; Look for simple.el or simple.elc and use their directory + ;; as the place where all Lisp files live. + (locate-file "simple" load-path (get-load-suffixes)))) + ;; Don't abort if simple.el cannot be found, but print a warning. + ;; Although in most usage we are going to cryptically abort a moment + ;; later anyway, due to missing required bidi data files (eg bug#13430). + (if (null simple-file-name) + (let ((standard-output 'external-debugging-output) + (lispdir (expand-file-name "../lisp" data-directory))) + (princ "Warning: Could not find simple.el or simple.elc") + (terpri) + (when (getenv "EMACSLOADPATH") + (princ "The EMACSLOADPATH environment variable is set, \ please check its value") - (terpri)) - (unless (file-readable-p lispdir) - (princ (format "Lisp directory %s not readable?" lispdir)) - (terpri))) - (setq lisp-directory - (file-truename (file-name-directory simple-file-name))) - (setq load-history - (mapcar (lambda (elt) - (if (and (stringp (car elt)) - (not (file-name-absolute-p (car elt)))) - (cons (concat lisp-directory - (car elt)) - (cdr elt)) - elt)) - load-history)))) - - ;; Convert the arguments to Emacs internal representation. - (let ((args command-line-args)) - (while args - (setcar args - (decode-coding-string (car args) locale-coding-system t)) - (pop args))) - - (let ((done nil) - (args (cdr command-line-args)) - display-arg) - - ;; Figure out which user's init file to load, - ;; either from the environment or from the options. - (setq init-file-user (if noninteractive nil (user-login-name))) - ;; If user has not done su, use current $HOME to find .emacs. - (and init-file-user - (equal init-file-user (user-real-login-name)) - (setq init-file-user "")) - - ;; Process the command-line args, and delete the arguments - ;; processed. This is consistent with the way main in emacs.c - ;; does things. - (while (and (not done) args) - (let* ((longopts '(("--no-init-file") ("--no-site-file") - ("--no-x-resources") ("--debug-init") - ("--user") ("--iconic") ("--icon-type") ("--quick") - ("--no-blinking-cursor") ("--basic-display") - ("--dump-file") ("--temacs") ("--seccomp") - ("--init-directory" "--no-comp-spawn"))) - (argi (pop args)) - (orig-argi argi) - argval) - ;; Handle --OPTION=VALUE format. - (when (string-match "\\`\\(--[^=]*\\)=" argi) - (setq argval (substring argi (match-end 0)) - argi (match-string 1 argi))) - (when (string-match "\\`--." orig-argi) - (let ((completion (try-completion argi longopts))) - (cond ((eq completion t) - (setq argi (substring argi 1))) - ((stringp completion) - (let ((elt (assoc completion longopts))) - (unless elt - (error "Option `%s' is ambiguous" argi)) - (setq argi (substring (car elt) 1)))) - (t - (setq argval nil - argi orig-argi))))) - - ;; We handle "-scripteval" further down, but we have to - ;; inhibit loading the user init file first. (This is for - ;; "emacs -x" handling.) - (when (equal argi "-scripteval") - (setq init-file-user nil - noninteractive t)) - - (cond - ;; The --display arg is handled partly in C, partly in Lisp. - ;; When it shows up here, we just put it back to be handled - ;; by `command-line-1'. - ((member argi '("-d" "-display")) - (setq display-arg (list argi (pop args)))) - ((member argi '("-Q" "-quick")) - (setq init-file-user nil - site-run-file nil - inhibit-x-resources t) - ;; Stop it showing up in emacs -Q's customize-rogue. - (put 'site-run-file 'standard-value '(nil))) - ((member argi '("-no-x-resources")) - (setq inhibit-x-resources t)) - ((member argi '("-D" "-basic-display")) - (setq no-blinking-cursor t - emacs-basic-display t) - (push '(vertical-scroll-bars . nil) initial-frame-alist)) - ((member argi '("-q" "-no-init-file")) - (setq init-file-user nil)) - ((member argi '("-init-directory")) - (setq user-emacs-directory (or argval (pop args)) - user-emacs-directory (if (stringp user-emacs-directory) - (file-name-as-directory - (expand-file-name - user-emacs-directory - command-line-default-directory)) - user-emacs-directory) - argval nil)) - ((member argi '("-u" "-user")) - (setq init-file-user (or argval (pop args)) - argval nil)) - ((equal argi "-no-site-file") - (setq site-run-file nil) - (put 'site-run-file 'standard-value '(nil))) - ((equal argi "-no-comp-spawn") - (defvar comp-no-spawn) - (setq comp-no-spawn t)) - ((equal argi "-debug-init") - (setq init-file-debug t)) - ((equal argi "-iconic") - (push '(visibility . icon) initial-frame-alist)) - ((member argi '("-nbc" "-no-blinking-cursor")) - (setq no-blinking-cursor t)) - ((member argi '("-dump-file" "-temacs" "-seccomp")) - ;; Handled in C - (or argval (pop args)) - (setq argval nil)) - ;; Push the popped arg back on the list of arguments. - (t - (push argi args) - (setq done t))) - ;; Was argval set but not used? - (and argval - (error "Option `%s' doesn't allow an argument" argi)))) - - ;; Re-attach the --display arg. - (and display-arg (setq args (append display-arg args))) - - ;; Re-attach the program name to the front of the arg list. - (and command-line-args - (setcdr command-line-args args))) - - ;; Re-evaluate predefined variables whose initial value depends on - ;; the runtime context. But delay the warning about - ;; `user-emacs-directory' being inaccessible until after processing - ;; the init file and the command-line arguments, in case the user - ;; customized `user-emacs-directory-warning' to nil via those. - (let ((user-emacs-directory-warning nil)) - (when (listp custom-delayed-init-variables) - (mapc #'custom-reevaluate-setting - ;; Initialize them in the same order they were loaded, in - ;; case there are dependencies between them. - (reverse custom-delayed-init-variables)))) - (setq custom-delayed-init-variables t) - - ;; Warn for invalid user name. - (when init-file-user - (if (string-match "[~/:\n]" init-file-user) - (display-warning 'initialization - (format "Invalid user name %s" - init-file-user) - :error) - (if (file-directory-p (expand-file-name - ;; We don't support ~USER on MS-Windows - ;; and MS-DOS except for the current - ;; user, and always load .emacs from - ;; the current user's home directory - ;; (see below). So always check "~", - ;; even if invoked with "-u USER", or - ;; if $USER or $LOGNAME are set to - ;; something different. - (if (memq system-type '(windows-nt ms-dos)) - "~" - (concat "~" init-file-user)))) - nil - (display-warning 'initialization - (format "User %s has no home directory" - (if (equal init-file-user "") - (user-real-login-name) - init-file-user)) - :error)))) - - ;; Calculate the name of the Emacs init directory. - ;; This is typically ~INIT-FILE-USER/.config/emacs unless the user - ;; is following the ~INIT-FILE-USER/.emacs.d convention. - (setq xdg-dir startup--xdg-config-home-emacs) - (setq startup-init-directory - (if (or (zerop (length init-file-user)) - (and (eq xdg-dir user-emacs-directory) - (not (eq xdg-dir startup--xdg-config-default)))) - user-emacs-directory - ;; The name is not obvious, so access more directories - ;; to calculate it. - (setq xdg-dir (concat "~" init-file-user "/.config/emacs/")) - (startup--xdg-or-homedot xdg-dir init-file-user))) - - ;; Load the early init file, if found. - (startup--load-user-init-file - (lambda () - (expand-file-name - ;; We use an explicit .el extension here to force - ;; startup--load-user-init-file to set user-init-file to "early-init.el", - ;; with the .el extension, if the file doesn't exist, not just - ;; "early-init" without an extension, as it does for ".emacs". - "early-init.el" - startup-init-directory))) - (setq early-init-file user-init-file) - - ;; Amend `native-comp-eln-load-path', since the early-init file may - ;; have altered `user-emacs-directory' and/or changed the eln-cache - ;; directory. - (when (featurep 'native-compile) - (startup--update-eln-cache)) - - ;; Make sure window system's init file was loaded in loadup.el if - ;; using a window system. - ;; Initialize the window-system only after processing the command-line - ;; args so that -Q can influence this initialization. - (condition-case error - (unless noninteractive - (if (and initial-window-system - (not (featurep - (intern - (concat (symbol-name initial-window-system) "-win"))))) - (error "Unsupported window system `%s'" initial-window-system)) - ;; Process window-system specific command line parameters. - (setq command-line-args - (let ((window-system initial-window-system)) ;Hack attack! - (handle-args-function command-line-args))) - ;; Initialize the window system. (Open connection, etc.) - (let ((window-system initial-window-system)) ;Hack attack! - (window-system-initialization)) - (put initial-window-system 'window-system-initialized t)) - ;; If there was an error, print the error message and exit. - (error - (princ - (if (eq (car error) 'error) - (apply #'concat (cdr error)) - (if (memq 'file-error (get (car error) 'error-conditions)) - (format "%s: %s" - (nth 1 error) - (mapconcat (lambda (obj) (prin1-to-string obj t)) - (cdr (cdr error)) ", ")) - (format "%s: %s" - (get (car error) 'error-message) - (mapconcat (lambda (obj) (prin1-to-string obj t)) - (cdr error) ", ")))) - 'external-debugging-output) - (terpri 'external-debugging-output) - (setq initial-window-system nil) - (kill-emacs))) - - (run-hooks 'before-init-hook) - - ;; Under X, create the X frame and delete the terminal frame. - (unless (daemonp) - (if (or noninteractive emacs-basic-display) - (setq menu-bar-mode nil - tab-bar-mode nil - tool-bar-mode nil)) - (frame-initialize)) - - (when (fboundp 'x-create-frame) - ;; Set up the tool-bar (even in tty frames, since Emacs might open a - ;; graphical frame later). - (unless noninteractive - (tool-bar-setup))) - - (unless noninteractive - (startup--setup-quote-display) - (setq internal--text-quoting-flag t)) - - (normal-erase-is-backspace-setup-frame) - - ;; Register default TTY colors for the case the terminal hasn't a - ;; terminal init file. We do this regardless of whether the terminal - ;; supports colors or not and regardless the current display type, - ;; since users can connect to color-capable terminals and also - ;; switch color support on or off in mid-session by setting the - ;; tty-color-mode frame parameter. - ;; Exception: the `pc' ``window system'' has only 16 fixed colors, - ;; and they are already set at this point by a suitable method of - ;; window-system-initialization. - (or (eq initial-window-system 'pc) - (tty-register-default-colors)) - - (let ((old-scalable-fonts-allowed scalable-fonts-allowed) - (old-face-ignored-fonts face-ignored-fonts)) - - ;; Run the site-start library if it exists. The point of this file is - ;; that it is run before .emacs. There is no point in doing this after - ;; .emacs; that is useless. - ;; Note that user-init-file is nil at this point. Code that might - ;; be loaded from site-run-file and wants to test if -q was given - ;; should check init-file-user instead, since that is already set. - ;; See cus-edit.el for an example. - (if site-run-file - ;; Sites should not disable the startup screen. - ;; Only individuals should disable the startup screen. - (let ((inhibit-startup-screen inhibit-startup-screen)) - (load site-run-file t t))) - - ;; Load that user's init file, or the default one, or none. + (terpri)) + (unless (file-readable-p lispdir) + (princ (format "Lisp directory %s not readable?" lispdir)) + (terpri))) + (setq lisp-directory + (file-truename (file-name-directory simple-file-name))) + (setq load-history + (mapcar (lambda (elt) + (if (and (stringp (car elt)) + (not (file-name-absolute-p (car elt)))) + (cons (concat lisp-directory + (car elt)) + (cdr elt)) + elt)) + load-history)))) + + ;; Convert the arguments to Emacs internal representation. + (let ((args command-line-args)) + (while args + (setcar args + (decode-coding-string (car args) locale-coding-system t)) + (pop args))) + + (let ((done nil) + (args (cdr command-line-args)) + display-arg) + + ;; Figure out which user's init file to load, + ;; either from the environment or from the options. + (setq init-file-user (if noninteractive nil (user-login-name))) + ;; If user has not done so, use current $HOME to find .emacs. + (and init-file-user + (equal init-file-user (user-real-login-name)) + (setq init-file-user "")) + + ;; Process the command-line args, and delete the arguments + ;; processed. This is consistent with the way main in emacs.c + ;; does things. + (while (and (not done) args) + (let* ((longopts '(("--no-init-file") ("--no-site-file") + ("--no-x-resources") ("--debug-init") + ("--user") ("--iconic") ("--icon-type") ("--quick") + ("--no-blinking-cursor") ("--basic-display") + ("--dump-file") ("--temacs") ("--seccomp") + ("--init-directory" "--no-comp-spawn"))) + (argi (pop args)) + (orig-argi argi) + argval) + ;; Handle --OPTION=VALUE format. + (when (string-match "\\`\\(--[^=]*\\)=" argi) + (setq argval (substring argi (match-end 0)) + argi (match-string 1 argi))) + (when (string-match "\\`--." orig-argi) + (let ((completion (try-completion argi longopts))) + (cond ((eq completion t) + (setq argi (substring argi 1))) + ((stringp completion) + (let ((elt (assoc completion longopts))) + (unless elt + (error "Option `%s' is ambiguous" argi)) + (setq argi (substring (car elt) 1)))) + (t + (setq argval nil + argi orig-argi))))) + + ;; We handle "-scripteval" further down, but we have to + ;; inhibit loading the user init file first. (This is for + ;; "emacs -x" handling.) + (when (equal argi "-scripteval") + (setq init-file-user nil + noninteractive t)) + + (cond + ;; The --display arg is handled partly in C, partly in Lisp. + ;; When it shows up here, we just put it back to be handled + ;; by `command-line-1'. + ((member argi '("-d" "-display")) + (setq display-arg (list argi (pop args)))) + ((member argi '("-Q" "-quick")) + (setq init-file-user nil + site-run-file nil + inhibit-x-resources t) + ;; Stop it showing up in emacs -Q's customize-rogue. + (put 'site-run-file 'standard-value '(nil))) + ((member argi '("-no-x-resources")) + (setq inhibit-x-resources t)) + ((member argi '("-q" "-no-init-file")) + (setq init-file-user nil)) + ((member argi '("-init-directory")) + (setq user-emacs-directory (or argval (pop args)) + user-emacs-directory (if (stringp user-emacs-directory) + (file-name-as-directory + (expand-file-name + user-emacs-directory + command-line-default-directory)) + user-emacs-directory) + argval nil)) + ((member argi '("-u" "-user")) + (setq init-file-user (or argval (pop args)) + argval nil)) + ((equal argi "-no-site-file") + (setq site-run-file nil) + (put 'site-run-file 'standard-value '(nil))) + ((equal argi "-no-comp-spawn") + (defvar comp-no-spawn) + (setq comp-no-spawn t)) + ((equal argi "-debug-init") + (setq init-file-debug t)) + ((equal argi "-iconic") + (push '(visibility . icon) initial-frame-alist)) + ((member argi '("-dump-file" "-temacs" "-seccomp")) + ;; Handled in C + (or argval (pop args)) + (setq argval nil)) + ;; Push the popped arg back on the list of arguments. + (t + (push argi args) + (setq done t))) + ;; Was argval set but not used? + (and argval + (error "Option `%s' doesn't allow an argument" argi)))) + + ;; Re-attach the --display arg. + (and display-arg (setq args (append display-arg args))) + + ;; Re-attach the program name to the front of the arg list. + (and command-line-args + (setcdr command-line-args args))) + + ;; Re-evaluate predefined variables whose initial value depends on + ;; the runtime context. But delay the warning about + ;; `user-emacs-directory' being inaccessible until after processing + ;; the init file and the command-line arguments, in case the user + ;; customized `user-emacs-directory-warning' to nil via those. + (let ((user-emacs-directory-warning nil)) + (when (listp custom-delayed-init-variables) + (mapc #'custom-reevaluate-setting + ;; Initialize them in the same order they were loaded, in + ;; case there are dependencies between them. + (reverse custom-delayed-init-variables)))) + (setq custom-delayed-init-variables t) + + ;; Warn for invalid user name. + (when init-file-user + (if (string-match "[~/:\n]" init-file-user) + (display-warning 'initialization + (format "Invalid user name %s" + init-file-user) + :error) + (if (file-directory-p (expand-file-name + ;; We don't support ~USER on MS-Windows + ;; and MS-DOS except for the current + ;; user, and always load .emacs from + ;; the current user's home directory + ;; (see below). So always check "~", + ;; even if invoked with "-u USER", or + ;; if $USER or $LOGNAME are set to + ;; something different. + (if (memq system-type '(windows-nt ms-dos)) + "~" + (concat "~" init-file-user)))) + nil + (display-warning 'initialization + (format "User %s has no home directory" + (if (equal init-file-user "") + (user-real-login-name) + init-file-user)) + :error)))) + + ;; Calculate the name of the Emacs init directory. + ;; This is typically ~INIT-FILE-USER/.config/emacs unless the user + ;; is following the ~INIT-FILE-USER/.emacs.d convention. + (setq xdg-dir startup--xdg-config-home-emacs) + (setq startup-init-directory + (if (or (zerop (length init-file-user)) + (and (eq xdg-dir user-emacs-directory) + (not (eq xdg-dir startup--xdg-config-default)))) + user-emacs-directory + ;; The name is not obvious, so access more directories + ;; to calculate it. + (setq xdg-dir (concat "~" init-file-user "/.config/emacs/")) + (startup--xdg-or-homedot xdg-dir init-file-user))) + + ;; Load the early init file, if found. (startup--load-user-init-file - (lambda () - (cond - ((eq startup-init-directory xdg-dir) nil) - ((eq system-type 'ms-dos) - (concat "~" init-file-user "/_emacs")) - ((not (eq system-type 'windows-nt)) - (concat "~" init-file-user "/.emacs")) - ;; Else deal with the Windows situation. - ((directory-files "~" nil "\\`\\.emacs\\(\\.elc?\\)?\\'") - ;; Prefer .emacs on Windows. - "~/.emacs") - ((directory-files "~" nil "\\`_emacs\\(\\.elc?\\)?\\'") - ;; Also support _emacs for compatibility, but warn about it. - (push `(initialization - ,(format-message - "`_emacs' init file is deprecated, please use `.emacs'")) - delayed-warnings-list) - "~/_emacs") - (t ;; But default to .emacs if _emacs does not exist. - "~/.emacs"))) (lambda () (expand-file-name - "init.el" - startup-init-directory)) - t) - - ;; Amend `native-comp-eln-load-path' again, since the early-init - ;; file may have altered `user-emacs-directory' and/or changed the - ;; eln-cache directory. + ;; We use an explicit .el extension here to force + ;; startup--load-user-init-file to set user-init-file to "early-init.el", + ;; with the .el extension, if the file doesn't exist, not just + ;; "early-init" without an extension, as it does for ".emacs". + "early-init.el" + startup-init-directory))) + (setq early-init-file user-init-file) + + ;; Amend `native-comp-eln-load-path', since the early-init file may + ;; have altered `user-emacs-directory' and/or changed the eln-cache + ;; directory. (when (featurep 'native-compile) (startup--update-eln-cache)) - (when (and deactivate-mark transient-mark-mode) - (with-current-buffer (window-buffer) - (deactivate-mark))) - - ;; If the user has a file of abbrevs, read it (unless -batch). - (when (and (not noninteractive) - (file-exists-p abbrev-file-name) - (file-readable-p abbrev-file-name)) - (quietly-read-abbrev-file abbrev-file-name)) - - ;; If the abbrevs came entirely from the init file or the - ;; abbrevs file, they do not need saving. - (setq abbrevs-changed nil) - - ;; Do this here in case the init file sets mail-host-address. - (and mail-host-address - ;; Check that user-mail-address has not been set by hand. - ;; Yes, this is ugly, but slightly less so than leaving - ;; user-mail-address uninitialized during init file processing. - ;; Perhaps we should make :set-after do something like this? - ;; Ie, extend it to also mean (re)initialize-after. See etc/TODO. - (equal user-mail-address - (let (mail-host-address) - (ignore-errors - (custom--standard-value 'user-mail-address)))) - (custom-reevaluate-setting 'user-mail-address)) - - ;; If parameter have been changed in the init file which influence - ;; face realization, clear the face cache so that new faces will - ;; be realized. - (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed) - (eq face-ignored-fonts old-face-ignored-fonts)) - (clear-face-cache))) - - (setq after-init-time (current-time)) - ;; Display any accumulated warnings after all functions in - ;; `after-init-hook' like `desktop-read' have finalized possible - ;; changes in the window configuration. - (run-hooks 'after-init-hook 'delayed-warnings-hook) - - ;; If *scratch* exists and init file didn't change its mode, initialize it. - (if (get-buffer "*scratch*") - (with-current-buffer "*scratch*" - (if (eq major-mode 'fundamental-mode) - (funcall initial-major-mode)))) - - ;; Load library for our terminal type. - ;; User init file can set term-file-prefix to nil to prevent this. - (unless (or noninteractive - initial-window-system - (daemonp)) - (tty-run-terminal-initialization (selected-frame) nil t)) - - ;; Update the out-of-memory error message based on user's key bindings - ;; for save-some-buffers. - (setq memory-signal-data - (list 'error - (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs"))) - - ;; Reevaluate `user-emacs-directory-warning' before processing - ;; '--eval' arguments, so that the user could override the default - ;; value in the '--eval' forms. - (custom-reevaluate-setting 'user-emacs-directory-warning) - - ;; Process the remaining args. - (command-line-1 (cdr command-line-args)) - - ;; Check if `user-emacs-directory' is accessible and warn if it - ;; isn't, unless `user-emacs-directory-warning' was customized to - ;; disable that warning. - (when (and user-emacs-directory-warning - (not (file-accessible-directory-p user-emacs-directory))) - (locate-user-emacs-file "")) - - ;; This is a problem because, e.g. if emacs.d/gnus.el exists, - ;; trying to load gnus could load the wrong file. - ;; OK, it would not matter if .emacs.d were at the end of load-path. - ;; but for the sake of simplicity, we discourage it full-stop. - ;; Ref eg https://lists.gnu.org/r/emacs-devel/2012-03/msg00056.html - ;; - ;; A bad element could come from user-emacs-file, the command line, - ;; or EMACSLOADPATH, so we basically always have to check. - (let (warned) - (dolist (dir load-path) - (and (not noninteractive) - (not warned) - (stringp dir) - (string-equal (file-name-as-directory (expand-file-name dir)) - (expand-file-name user-emacs-directory)) - (setq warned t) - (display-warning 'initialization - (format-message "\ + ;; Make sure window system's init file was loaded in loadup.el if + ;; using a window system. + ;; Initialize the window-system only after processing the command-line + ;; args so that -Q can influence this initialization. + (condition-case error + (unless noninteractive + (if (and initial-window-system + (not (featurep + (intern + (concat (symbol-name initial-window-system) "-win"))))) + (error "Unsupported window system `%s'" initial-window-system)) + ;; Process window-system specific command line parameters. + (setq command-line-args + (let ((window-system initial-window-system)) ;Hack attack! + (handle-args-function command-line-args))) + ;; Initialize the window system. (Open connection, etc.) + (let ((window-system initial-window-system)) ;Hack attack! + (window-system-initialization)) + (put initial-window-system 'window-system-initialized t)) + ;; If there was an error, print the error message and exit. + (error + (princ + (if (eq (car error) 'error) + (apply #'concat (cdr error)) + (if (memq 'file-error (get (car error) 'error-conditions)) + (format "%s: %s" + (nth 1 error) + (mapconcat (lambda (obj) (prin1-to-string obj t)) + (cdr (cdr error)) ", ")) + (format "%s: %s" + (get (car error) 'error-message) + (mapconcat (lambda (obj) (prin1-to-string obj t)) + (cdr error) ", ")))) + 'external-debugging-output) + (terpri 'external-debugging-output) + (setq initial-window-system nil) + (kill-emacs))) + + (run-hooks 'before-init-hook) + + ;; Under X, create the X frame and delete the terminal frame. + (unless (daemonp) + (if noninteractive + (setq menu-bar-mode nil + tab-bar-mode nil + tool-bar-mode nil)) + (frame-initialize)) + + (when (fboundp 'x-create-frame) + ;; Set up the tool-bar (even in tty frames, since Emacs might open a + ;; graphical frame later). + (unless noninteractive + (tool-bar-setup))) + + (unless noninteractive + (startup--setup-quote-display) + (setq internal--text-quoting-flag t)) + + (normal-erase-is-backspace-setup-frame) + + ;; Register default TTY colors for the case the terminal hasn't a + ;; terminal init file. We do this regardless of whether the terminal + ;; supports colors or not and regardless the current display type, + ;; since users can connect to color-capable terminals and also + ;; switch color support on or off in mid-session by setting the + ;; tty-color-mode frame parameter. + ;; Exception: the `pc' ``window system'' has only 16 fixed colors, + ;; and they are already set at this point by a suitable method of + ;; window-system-initialization. + (or (eq initial-window-system 'pc) + (tty-register-default-colors)) + + (let ((old-scalable-fonts-allowed scalable-fonts-allowed) + (old-face-ignored-fonts face-ignored-fonts)) + + ;; Run the site-start library if it exists. The point of this file is + ;; that it is run before .emacs. There is no point in doing this after + ;; .emacs; that is useless. + ;; Note that user-init-file is nil at this point. Code that might + ;; be loaded from site-run-file and wants to test if -q was given + ;; should check init-file-user instead, since that is already set. + ;; See cus-edit.el for an example. + (if site-run-file + ;; Sites should not disable the startup screen. + ;; Only individuals should disable the startup screen. + (let ((inhibit-startup-screen inhibit-startup-screen)) + (load site-run-file t t))) + + ;; Load that user's init file, or the default one, or none. + (startup--load-user-init-file + (lambda () + (cond + ((eq startup-init-directory xdg-dir) nil) + ((eq system-type 'ms-dos) + (concat "~" init-file-user "/_emacs")) + ((not (eq system-type 'windows-nt)) + (concat "~" init-file-user "/.emacs")) + ;; Else deal with the Windows situation. + ((directory-files "~" nil "\\`\\.emacs\\(\\.elc?\\)?\\'") + ;; Prefer .emacs on Windows. + "~/.emacs") + ((directory-files "~" nil "\\`_emacs\\(\\.elc?\\)?\\'") + ;; Also support _emacs for compatibility, but warn about it. + (push `(initialization + ,(format-message + "`_emacs' init file is deprecated, please use `.emacs'")) + delayed-warnings-list) + "~/_emacs") + (t ;; But default to .emacs if _emacs does not exist. + "~/.emacs"))) + (lambda () + (expand-file-name + "init.el" + startup-init-directory)) + t) + + ;; Amend `native-comp-eln-load-path' again, since the early-init + ;; file may have altered `user-emacs-directory' and/or changed the + ;; eln-cache directory. + (when (featurep 'native-compile) + (startup--update-eln-cache)) + + (when (and deactivate-mark transient-mark-mode) + (with-current-buffer (window-buffer) + (deactivate-mark))) + + ;; Do this here in case the init file sets mail-host-address. + (and mail-host-address + ;; Check that user-mail-address has not been set by hand. + ;; Yes, this is ugly, but slightly less so than leaving + ;; user-mail-address uninitialized during init file processing. + ;; Perhaps we should make :set-after do something like this? + ;; Ie, extend it to also mean (re)initialize-after. See etc/TODO. + (equal user-mail-address + (let (mail-host-address) + (ignore-errors + (custom--standard-value 'user-mail-address)))) + (custom-reevaluate-setting 'user-mail-address)) + + ;; If parameter have been changed in the init file which influence + ;; face realization, clear the face cache so that new faces will + ;; be realized. + (unless (and (eq scalable-fonts-allowed old-scalable-fonts-allowed) + (eq face-ignored-fonts old-face-ignored-fonts)) + (clear-face-cache))) + + (setq after-init-time (current-time)) + ;; Display any accumulated warnings after all functions in + ;; `after-init-hook' like `desktop-read' have finalized possible + ;; changes in the window configuration. + (run-hooks 'after-init-hook 'delayed-warnings-hook) + + ;; If *scratch* exists and init file didn't change its mode, initialize it. + (if (get-buffer "*scratch*") + (with-current-buffer "*scratch*" + (if (eq major-mode 'fundamental-mode) + (funcall initial-major-mode)))) + + ;; Load library for our terminal type. + ;; User init file can set term-file-prefix to nil to prevent this. + (unless (or noninteractive + initial-window-system + (daemonp)) + (tty-run-terminal-initialization (selected-frame) nil t)) + + ;; Update the out-of-memory error message based on user's key bindings + ;; for save-some-buffers. + (setq memory-signal-data + (list 'error + (substitute-command-keys "Memory exhausted--use \\[save-some-buffers] then exit and restart Emacs"))) + + ;; Reevaluate `user-emacs-directory-warning' before processing + ;; '--eval' arguments, so that the user could override the default + ;; value in the '--eval' forms. + (custom-reevaluate-setting 'user-emacs-directory-warning) + + ;; Process the remaining args. + (command-line-1 (cdr command-line-args)) + + ;; Check if `user-emacs-directory' is accessible and warn if it + ;; isn't, unless `user-emacs-directory-warning' was customized to + ;; disable that warning. + (when (and user-emacs-directory-warning + (not (file-accessible-directory-p user-emacs-directory))) + (locate-user-emacs-file "")) + + ;; This is a problem because, e.g. if emacs.d/gnus.el exists, + ;; trying to load gnus could load the wrong file. + ;; OK, it would not matter if .emacs.d were at the end of load-path. + ;; but for the sake of simplicity, we discourage it full-stop. + ;; Ref eg https://lists.gnu.org/r/emacs-devel/2012-03/msg00056.html + ;; + ;; A bad element could come from user-emacs-file, the command line, + ;; or EMACSLOADPATH, so we basically always have to check. + (let (warned) + (dolist (dir load-path) + (and (not noninteractive) + (not warned) + (stringp dir) + (string-equal (file-name-as-directory (expand-file-name dir)) + (expand-file-name user-emacs-directory)) + (setq warned t) + (display-warning 'initialization + (format-message "\ Your `load-path' seems to contain\n\ your `user-emacs-directory': %s\n\ This is likely to cause problems...\n\ Consider using a subdirectory instead, e.g.: %s" - dir (expand-file-name - "lisp" user-emacs-directory)) - :warning)))) - - ;; If -batch, terminate after processing the command options. - (if noninteractive (kill-emacs t)) - - ;; In daemon mode, start the server to allow clients to connect. - ;; This is done after loading the user's init file and after - ;; processing all command line arguments to allow e.g. `server-name' - ;; to be changed before the server starts. - (let ((dn (daemonp))) - (when dn - (when (stringp dn) (setq server-name dn)) - (condition-case err - (server-start) - (error (error "Unable to start daemon: %s; exiting" (error-message-string err)))) - (if server-process - (daemon-initialized) - (if (stringp dn) - (message - "Unable to start daemon: Emacs server named %S already running" - server-name) - (message "Unable to start the daemon.\nAnother instance of Emacs is running the server, either as daemon or interactively.\nYou can use emacsclient to connect to that Emacs process.")) - (kill-emacs 1)))) - - ;; Run emacs-session-restore (session management) if started by - ;; the session manager and we have a session manager connection. - (if (and (boundp 'x-session-previous-id) - (stringp x-session-previous-id)) - (with-no-warnings - (emacs-session-restore x-session-previous-id))))) + dir (expand-file-name + "lisp" user-emacs-directory)) + :warning)))) + + ;; If -batch, terminate after processing the command options. + (if noninteractive (kill-emacs t)) + + ;; In daemon mode, start the server to allow clients to connect. + ;; This is done after loading the user's init file and after + ;; processing all command line arguments to allow e.g. `server-name' + ;; to be changed before the server starts. + (let ((dn (daemonp))) + (when dn + (when (stringp dn) (setq server-name dn)) + (condition-case err + (server-start) + (error (error "Unable to start daemon: %s; exiting" (error-message-string err)))) + (if server-process + (daemon-initialized) + (if (stringp dn) + (message + "Unable to start daemon: Emacs server named %S already running" + server-name) + (message "Unable to start the daemon.\nAnother instance of Emacs is running the server, either as daemon or interactively.\nYou can use emacsclient to connect to that Emacs process.")) + (kill-emacs 1)))) + + ;; Run emacs-session-restore (session management) if started by + ;; the session manager and we have a session manager connection. + (if (and (boundp 'x-session-previous-id) + (stringp x-session-previous-id)) + (with-no-warnings + (emacs-session-restore x-session-previous-id))))) (defun x-apply-session-resources () "Apply X resources which specify initial values for Emacs variables. @@ -2850,7 +2802,7 @@ nil default-directory" name) ;; If there are no switches to process, we might as well ;; run this hook now, and there may be some need to do it ;; before doing any output. - (run-hooks 'emacs-startup-hook 'term-setup-hook) + (run-hooks 'emacs-startup-hook) ;; See the commentary in `normal-top-level' for why we do ;; this. diff --git a/src/buffer.c b/src/buffer.c index a408b799ff4..9e601738c0c 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -153,16 +153,6 @@ fix_position (Lisp_Object pos) /* These setters are used only in this file, so they can be private. The public setters are inline functions defined in buffer.h. */ static void -bset_abbrev_mode (struct buffer *b, Lisp_Object val) -{ - b->abbrev_mode_ = val; -} -static void -bset_abbrev_table (struct buffer *b, Lisp_Object val) -{ - b->abbrev_table_ = val; -} -static void bset_auto_fill_function (struct buffer *b, Lisp_Object val) { b->auto_fill_function_ = val; @@ -4708,7 +4698,6 @@ init_buffer_once (void) idx = 1; XSETFASTINT (BVAR (&buffer_local_flags, mode_line_format), idx); ++idx; - XSETFASTINT (BVAR (&buffer_local_flags, abbrev_mode), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, overwrite_mode), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, auto_fill_function), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, selective_display), idx); ++idx; @@ -4721,7 +4710,6 @@ init_buffer_once (void) XSETFASTINT (BVAR (&buffer_local_flags, ctl_arrow), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, fill_column), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, left_margin), idx); ++idx; - XSETFASTINT (BVAR (&buffer_local_flags, abbrev_table), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, display_table), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, syntax_table), idx); ++idx; XSETFASTINT (BVAR (&buffer_local_flags, cache_long_scans), idx); ++idx; @@ -4800,12 +4788,10 @@ init_buffer_once (void) bset_mode_line_format (&buffer_defaults, build_string ("%-")); bset_header_line_format (&buffer_defaults, Qnil); bset_tab_line_format (&buffer_defaults, Qnil); - bset_abbrev_mode (&buffer_defaults, Qnil); bset_overwrite_mode (&buffer_defaults, Qnil); bset_auto_fill_function (&buffer_defaults, Qnil); bset_selective_display (&buffer_defaults, Qnil); bset_selective_display_ellipses (&buffer_defaults, Qt); - bset_abbrev_table (&buffer_defaults, Qnil); bset_display_table (&buffer_defaults, Qnil); bset_undo_list (&buffer_defaults, Qnil); bset_mark_active (&buffer_defaults, Qnil); @@ -5182,13 +5168,6 @@ Usually a string, but can use any of the constructs for `mode-line-format', which see. Format with `format-mode-line' to produce a string value. */); - DEFVAR_PER_BUFFER ("local-abbrev-table", &BVAR (current_buffer, abbrev_table), Qnil, - doc: /* Local (mode-specific) abbrev table of current buffer. */); - - DEFVAR_PER_BUFFER ("abbrev-mode", &BVAR (current_buffer, abbrev_mode), Qnil, - doc: /* Non-nil if Abbrev mode is enabled. -Use the command `abbrev-mode' to change this variable. */); - DEFVAR_PER_BUFFER ("fill-column", &BVAR (current_buffer, fill_column), Qintegerp, doc: /* Column beyond which automatic line-wrapping should happen. diff --git a/src/buffer.h b/src/buffer.h index d19ff22babd..9ea8c290322 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -370,9 +370,6 @@ struct buffer /* Keys that are bound local to this buffer. */ Lisp_Object keymap_; - /* This buffer's local abbrev table. */ - Lisp_Object abbrev_table_; - /* This buffer's syntax table. */ Lisp_Object syntax_table_; @@ -437,9 +434,6 @@ struct buffer overwrite newlines and tabs - for editing executables and the like. */ Lisp_Object overwrite_mode_; - /* Non-nil means abbrev mode is on. Expand abbrevs automatically. */ - Lisp_Object abbrev_mode_; - /* Display table to use for text in this buffer. */ Lisp_Object display_table_; diff --git a/src/cmds.c b/src/cmds.c index 9985855a0ce..81c1d8bad9c 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -314,7 +314,6 @@ internal_self_insert (int c, EMACS_INT n) { int hairy = 0; Lisp_Object tem; - register enum syntaxcode synt; Lisp_Object overwrite; /* Length of multi-byte form of C. */ int len; @@ -407,39 +406,6 @@ internal_self_insert (int c, EMACS_INT n) hairy = 2; } - synt = SYNTAX (c); - - if (!NILP (BVAR (current_buffer, abbrev_mode)) - && synt != Sword - && NILP (BVAR (current_buffer, read_only)) - && PT > BEGV - && (SYNTAX (!NILP (BVAR (current_buffer, enable_multibyte_characters)) - ? XFIXNAT (Fprevious_char ()) - : UNIBYTE_TO_CHAR (XFIXNAT (Fprevious_char ()))) - == Sword)) - { - modiff_count modiff = MODIFF; - Lisp_Object sym; - - sym = call0 (Qexpand_abbrev); - - /* If we expanded an abbrev which has a hook, - and the hook has a non-nil `no-self-insert' property, - return right away--don't really self-insert. */ - if (SYMBOLP (sym) && ! NILP (sym) - && ! NILP (XSYMBOL (sym)->u.s.function) - && SYMBOLP (XSYMBOL (sym)->u.s.function)) - { - Lisp_Object prop; - prop = Fget (XSYMBOL (sym)->u.s.function, Qno_self_insert); - if (! NILP (prop)) - return 1; - } - - if (MODIFF != modiff) - hairy = 2; - } - if (chars_to_delete) { int mc = ((NILP (BVAR (current_buffer, enable_multibyte_characters)) @@ -510,7 +476,6 @@ syms_of_cmds (void) DEFSYM (Qundo_auto_amalgamate, "undo-auto-amalgamate"); DEFSYM (Qundo_auto__this_command_amalgamating, "undo-auto--this-command-amalgamating"); - DEFSYM (Qno_self_insert, "no-self-insert"); DEFSYM (Qkill_forward_chars, "kill-forward-chars");