From 53b39e8977941c6b60deeeca3c0e54da9ec7961a Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 29 Oct 2013 22:14:16 -0400 Subject: [PATCH] * lisp/subr.el (custom-declare-variable-early): Remove function. (custom-declare-variable-list): Remove var. (error, user-error): Remove `while' loop. (read-quoted-char-radix, read-quoted-char): Move to simple.el. (user-emacs-directory-warning, locate-user-emacs-file): Move to files.el. * lisp/simple.el (read-quoted-char-radix, read-quoted-char): * lisp/files.el (user-emacs-directory-warning, locate-user-emacs-file): Move from subr.el. * lisp/custom.el (custom-declare-variable-list): Don't process custom-declare-variable-list. --- lisp/ChangeLog | 12 +++++ lisp/custom.el | 5 -- lisp/files.el | 51 +++++++++++++++++++ lisp/simple.el | 61 +++++++++++++++++++++++ lisp/subr.el | 133 +------------------------------------------------ 5 files changed, 126 insertions(+), 136 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 85fb2cbb73..d2c99e75f5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,17 @@ 2013-10-30 Stefan Monnier + * subr.el (custom-declare-variable-early): Remove function. + (custom-declare-variable-list): Remove var. + (error, user-error): Remove `while' loop. + (read-quoted-char-radix, read-quoted-char): Move to simple.el. + (user-emacs-directory-warning, locate-user-emacs-file): + Move to files.el. + * simple.el (read-quoted-char-radix, read-quoted-char): + * files.el (user-emacs-directory-warning, locate-user-emacs-file): + Move from subr.el. + * custom.el (custom-declare-variable-list): Don't process + custom-declare-variable-list. + * progmodes/python.el (python-shell-get-buffer): New function. (python-shell-get-process): Use it. (python-shell-send-string): Always use utf-8 and add a cookie to tell diff --git a/lisp/custom.el b/lisp/custom.el index d721198da0..0df22a8b89 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -1489,11 +1489,6 @@ This means reset VARIABLE. (The argument IGNORED is ignored)." ;;; The End. -;; Process the defcustoms for variables loaded before this file. -(while custom-declare-variable-list - (apply 'custom-declare-variable (car custom-declare-variable-list)) - (setq custom-declare-variable-list (cdr custom-declare-variable-list))) - (provide 'custom) ;;; custom.el ends here diff --git a/lisp/files.el b/lisp/files.el index cf3356014a..d44401b430 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -916,6 +916,57 @@ which we're looking." (setq file nil)))) (if root (file-name-as-directory root)))) +(defcustom user-emacs-directory-warning t + "Non-nil means warn if cannot access `user-emacs-directory'. +Set this to nil at your own risk..." + :type 'boolean + :group 'initialization + :version "24.4") + +(defun locate-user-emacs-file (new-name &optional old-name) + "Return an absolute per-user Emacs-specific file name. +If NEW-NAME exists in `user-emacs-directory', return it. +Else if OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME. +Else return NEW-NAME in `user-emacs-directory', creating the +directory if it does not exist." + (convert-standard-filename + (let* ((home (concat "~" (or init-file-user ""))) + (at-home (and old-name (expand-file-name old-name home))) + (bestname (abbreviate-file-name + (expand-file-name new-name user-emacs-directory)))) + (if (and at-home (not (file-readable-p bestname)) + (file-readable-p at-home)) + at-home + ;; Make sure `user-emacs-directory' exists, + ;; unless we're in batch mode or dumping Emacs. + (or noninteractive + purify-flag + (let (errtype) + (if (file-directory-p user-emacs-directory) + (or (file-accessible-directory-p user-emacs-directory) + (setq errtype "access")) + (let ((umask (default-file-modes))) + (unwind-protect + (progn + (set-default-file-modes ?\700) + (condition-case nil + (make-directory user-emacs-directory) + (error (setq errtype "create")))) + (set-default-file-modes umask)))) + (when (and errtype + user-emacs-directory-warning + (not (get 'user-emacs-directory-warning 'this-session))) + ;; Only warn once per Emacs session. + (put 'user-emacs-directory-warning 'this-session t) + (display-warning 'initialization + (format "\ +Unable to %s `user-emacs-directory' (%s). +Any data that would normally be written there may be lost! +If you never want to see this message again, +customize the variable `user-emacs-directory-warning'." + errtype user-emacs-directory))))) + bestname)))) + (defun executable-find (command) "Search for COMMAND in `exec-path' and return the absolute file name. diff --git a/lisp/simple.el b/lisp/simple.el index cd4df60e39..49108025a4 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -636,6 +636,67 @@ column specified by the function `current-left-margin'." (delete-horizontal-space t)) (indent-according-to-mode))) +(defcustom read-quoted-char-radix 8 + "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'. +Legitimate radix values are 8, 10 and 16." + :type '(choice (const 8) (const 10) (const 16)) + :group 'editing-basics) + +(defun read-quoted-char (&optional prompt) + "Like `read-char', but do not allow quitting. +Also, if the first character read is an octal digit, +we read any number of octal digits and return the +specified character code. Any nondigit terminates the sequence. +If the terminator is RET, it is discarded; +any other terminator is used itself as input. + +The optional argument PROMPT specifies a string to use to prompt the user. +The variable `read-quoted-char-radix' controls which radix to use +for numeric input." + (let ((message-log-max nil) done (first t) (code 0) translated) + (while (not done) + (let ((inhibit-quit first) + ;; Don't let C-h get the help message--only help function keys. + (help-char nil) + (help-form + "Type the special character you want to use, +or the octal character code. +RET terminates the character code and is discarded; +any other non-digit terminates the character code and is then used as input.")) + (setq translated (read-key (and prompt (format "%s-" prompt)))) + (if inhibit-quit (setq quit-flag nil))) + (if (integerp translated) + (setq translated (char-resolve-modifiers translated))) + (cond ((null translated)) + ((not (integerp translated)) + (setq unread-command-events + (listify-key-sequence (this-single-command-raw-keys)) + done t)) + ((/= (logand translated ?\M-\^@) 0) + ;; Turn a meta-character into a character with the 0200 bit set. + (setq code (logior (logand translated (lognot ?\M-\^@)) 128) + done t)) + ((and (<= ?0 translated) + (< translated (+ ?0 (min 10 read-quoted-char-radix)))) + (setq code (+ (* code read-quoted-char-radix) (- translated ?0))) + (and prompt (setq prompt (message "%s %c" prompt translated)))) + ((and (<= ?a (downcase translated)) + (< (downcase translated) + (+ ?a -10 (min 36 read-quoted-char-radix)))) + (setq code (+ (* code read-quoted-char-radix) + (+ 10 (- (downcase translated) ?a)))) + (and prompt (setq prompt (message "%s %c" prompt translated)))) + ((and (not first) (eq translated ?\C-m)) + (setq done t)) + ((not first) + (setq unread-command-events + (listify-key-sequence (this-single-command-raw-keys)) + done t)) + (t (setq code translated + done t))) + (setq first nil)) + code)) + (defun quoted-insert (arg) "Read next input character and insert it. This is useful for inserting control characters. diff --git a/lisp/subr.el b/lisp/subr.el index 0267366f1a..4df9c9a2a6 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -29,16 +29,6 @@ ;; Beware: while this file has tag `utf-8', before it's compiled, it gets ;; loaded as "raw-text", so non-ASCII chars won't work right during bootstrap. -(defvar custom-declare-variable-list nil - "Record `defcustom' calls made before `custom.el' is loaded to handle them. -Each element of this list holds the arguments to one call to `defcustom'.") - -;; Use this, rather than defcustom, in subr.el and other files loaded -;; before custom.el. -(defun custom-declare-variable-early (&rest arguments) - (setq custom-declare-variable-list - (cons arguments custom-declare-variable-list))) - (defmacro declare-function (_fn _file &optional _arglist _fileonly) "Tell the byte-compiler that function FN is defined, in FILE. Optional ARGLIST is the argument list used by the function. @@ -302,8 +292,7 @@ In Emacs, the convention is that error messages start with a capital letter but *do not* end with a period. Please follow this convention for the sake of consistency." (declare (advertised-calling-convention (string &rest args) "23.1")) - (while t - (signal 'error (list (apply 'format args))))) + (signal 'error (list (apply 'format args)))) (defun user-error (format &rest args) "Signal a pilot error, making error message by passing all args to `format'. @@ -313,8 +302,7 @@ for the sake of consistency. This is just like `error' except that `user-error's are expected to be the result of an incorrect manipulation on the part of the user, rather than the result of an actual problem." - (while t - (signal 'user-error (list (apply #'format format args))))) + (signal 'user-error (list (apply #'format format args)))) (defun define-error (name message &optional parent) "Define NAME as a new error signal. @@ -1943,17 +1931,6 @@ It can be retrieved with `(process-get PROCESS PROPNAME)'." ;;;; Input and display facilities. -(defvar read-quoted-char-radix 8 - "Radix for \\[quoted-insert] and other uses of `read-quoted-char'. -Legitimate radix values are 8, 10 and 16.") - -(custom-declare-variable-early - 'read-quoted-char-radix 8 - "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'. -Legitimate radix values are 8, 10 and 16." - :type '(choice (const 8) (const 10) (const 16)) - :group 'editing-basics) - (defconst read-key-empty-map (make-sparse-keymap)) (defvar read-key-delay 0.01) ;Fast enough for 100Hz repeat rate, hopefully. @@ -2009,61 +1986,6 @@ some sort of escape sequence, the ambiguity is resolved via `read-key-delay'." (cancel-timer timer) (use-global-map old-global-map)))) -(defun read-quoted-char (&optional prompt) - "Like `read-char', but do not allow quitting. -Also, if the first character read is an octal digit, -we read any number of octal digits and return the -specified character code. Any nondigit terminates the sequence. -If the terminator is RET, it is discarded; -any other terminator is used itself as input. - -The optional argument PROMPT specifies a string to use to prompt the user. -The variable `read-quoted-char-radix' controls which radix to use -for numeric input." - (let ((message-log-max nil) done (first t) (code 0) translated) - (while (not done) - (let ((inhibit-quit first) - ;; Don't let C-h get the help message--only help function keys. - (help-char nil) - (help-form - "Type the special character you want to use, -or the octal character code. -RET terminates the character code and is discarded; -any other non-digit terminates the character code and is then used as input.")) - (setq translated (read-key (and prompt (format "%s-" prompt)))) - (if inhibit-quit (setq quit-flag nil))) - (if (integerp translated) - (setq translated (char-resolve-modifiers translated))) - (cond ((null translated)) - ((not (integerp translated)) - (setq unread-command-events - (listify-key-sequence (this-single-command-raw-keys)) - done t)) - ((/= (logand translated ?\M-\^@) 0) - ;; Turn a meta-character into a character with the 0200 bit set. - (setq code (logior (logand translated (lognot ?\M-\^@)) 128) - done t)) - ((and (<= ?0 translated) - (< translated (+ ?0 (min 10 read-quoted-char-radix)))) - (setq code (+ (* code read-quoted-char-radix) (- translated ?0))) - (and prompt (setq prompt (message "%s %c" prompt translated)))) - ((and (<= ?a (downcase translated)) - (< (downcase translated) - (+ ?a -10 (min 36 read-quoted-char-radix)))) - (setq code (+ (* code read-quoted-char-radix) - (+ 10 (- (downcase translated) ?a)))) - (and prompt (setq prompt (message "%s %c" prompt translated)))) - ((and (not first) (eq translated ?\C-m)) - (setq done t)) - ((not first) - (setq unread-command-events - (listify-key-sequence (this-single-command-raw-keys)) - done t)) - (t (setq code translated - done t))) - (setq first nil)) - code)) - (defvar read-passwd-map ;; BEWARE: `defconst' would purecopy it, breaking the sharing with ;; minibuffer-local-map along the way! @@ -2574,57 +2496,6 @@ mode.") Various programs in Emacs store information in this directory. Note that this should end with a directory separator. See also `locate-user-emacs-file'.") - -(custom-declare-variable-early 'user-emacs-directory-warning t - "Non-nil means warn if cannot access `user-emacs-directory'. -Set this to nil at your own risk..." - :type 'boolean - :group 'initialization - :version "24.4") - -(defun locate-user-emacs-file (new-name &optional old-name) - "Return an absolute per-user Emacs-specific file name. -If NEW-NAME exists in `user-emacs-directory', return it. -Else if OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME. -Else return NEW-NAME in `user-emacs-directory', creating the -directory if it does not exist." - (convert-standard-filename - (let* ((home (concat "~" (or init-file-user ""))) - (at-home (and old-name (expand-file-name old-name home))) - (bestname (abbreviate-file-name - (expand-file-name new-name user-emacs-directory)))) - (if (and at-home (not (file-readable-p bestname)) - (file-readable-p at-home)) - at-home - ;; Make sure `user-emacs-directory' exists, - ;; unless we're in batch mode or dumping Emacs. - (or noninteractive - purify-flag - (let (errtype) - (if (file-directory-p user-emacs-directory) - (or (file-accessible-directory-p user-emacs-directory) - (setq errtype "access")) - (let ((umask (default-file-modes))) - (unwind-protect - (progn - (set-default-file-modes ?\700) - (condition-case nil - (make-directory user-emacs-directory) - (error (setq errtype "create")))) - (set-default-file-modes umask)))) - (when (and errtype - user-emacs-directory-warning - (not (get 'user-emacs-directory-warning 'this-session))) - ;; Only warn once per Emacs session. - (put 'user-emacs-directory-warning 'this-session t) - (display-warning 'initialization - (format "\ -Unable to %s `user-emacs-directory' (%s). -Any data that would normally be written there may be lost! -If you never want to see this message again, -customize the variable `user-emacs-directory-warning'." - errtype user-emacs-directory))))) - bestname)))) ;;;; Misc. useful functions. -- 2.20.1