diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-03-31 00:24:03 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-03-31 00:24:03 -0400 |
commit | 40d83b412f584cc02e68d4eac8fd5e6eb769e2fe (patch) | |
tree | b56f27a7e6d75a8c1fd27b00179a27b5efea0a32 /lisp | |
parent | f488fb6528738131ef41859e1f04125f2e50efce (diff) | |
parent | 44f230aa043ebb222aa0876b44d70484d5dd38db (diff) | |
download | emacs-40d83b412f584cc02e68d4eac8fd5e6eb769e2fe.tar.gz |
Merge from trunk
Diffstat (limited to 'lisp')
37 files changed, 940 insertions, 544 deletions
diff --git a/lisp/ChangeLog.trunk b/lisp/ChangeLog.trunk index d087982edee..7ce8b62b333 100644 --- a/lisp/ChangeLog.trunk +++ b/lisp/ChangeLog.trunk @@ -1,3 +1,154 @@ +2011-03-30 Leo Liu <sdl.web@gmail.com> + + * abbrev.el (abbrev-edit-save-to-file, abbrev-edit-save-buffer): + New commands. + (edit-abbrevs-map): Bind them here. + (write-abbrev-file): New optinal arg VERBOSE. (Bug#5937) + +2011-03-29 Ken Manheimer <ken.manheimer@gmail.com> + + * allout.el (allout-hide-by-annotation, allout-flag-region): + Reduce possibility of overlay leakage by making them volatile. + + * allout-widgets.el (allout-widgets-tally): Define as nil so the + hash is not shared between buffers. Mode initialization is + responsible for giving it a useful starting value. + (allout-item-span): Reduce possibility of overlay leakage by + making them volatile. + (allout-widgets-count-buttons-in-region): Add diagnostic function + for tracking down button overlay leaks. + +2011-03-29 Leo Liu <sdl.web@gmail.com> + + * ido.el (ido-read-internal): Use the default history var + minibuffer-history if no HISTORY is specified. + +2011-03-28 Brian T. Sniffen <bsniffen@akamai.com> (tiny change) + + * net/imap.el (imap-shell-open, imap-process-connection-type): Use + imap-process-connection-type for 'shell' streams as well as + Kerberos, SSL, other subprocesses. + +2011-03-28 Leo Liu <sdl.web@gmail.com> + + * abbrev.el (abbrev-table-empty-p): New function. + (prepare-abbrev-list-buffer): Place empty abbrev tables after + nonempty ones. (Bug#5937) + +2011-03-27 Jan Djärv <jan.h.d@swipnet.se> + + * cus-start.el (all): Add boolean ns-auto-hide-menu-bar. + +2011-03-27 Leo Liu <sdl.web@gmail.com> + + * ansi-color.el (ansi-color-names-vector): Allow cons cell value + for foreground and background colors. + (ansi-color-make-color-map): Adapt. + +2011-03-25 Leo Liu <sdl.web@gmail.com> + + * midnight.el (midnight-time-float): Remove. Note it calculates + the microsecond component incorrectly and seconds-to-time does the + same job. + Remove redundant (require 'timer). + + * ido.el (ido-read-internal): Simplify with read-from-minibuffer. + (ido-completions): Remove unused arguments. (Bug#8329) + +2011-03-24 Stefan Monnier <monnier@iro.umontreal.ca> + + * minibuffer.el (completion--flush-all-sorted-completions): + Remove itself from hook. + (completion-at-point): Let the functions perform the completion + immediately and return nil or t. + * comint.el (comint-dynamic-complete-functions): Now identical to + completion-at-point-functions. + (comint-dynamic-list-input-ring): Remove unused var `index'. + (comint--match-partial-filename, comint--unquote&expand-filename): + New funs, split from comint-match-partial-filename. + (comint-dynamic-complete): Use completion-at-point. + (comint-dynamic-complete-filename): Use comint--match-partial-filename. + +2011-03-24 Drew Adams <drew.adams@oracle.com> + + * thingatpt.el: Support `defun'. + +2011-03-23 Leo Liu <sdl.web@gmail.com> + + * abbrevlist.el: Move to obsolete/abbrevlist.el. + + * help-mode.el (help-mode-finish): Tweak regexp. + +2011-03-23 Glenn Morris <rgm@gnu.org> + + * eshell/esh-opt.el (eshell-eval-using-options): + Do not bind unused local variable `eshell-option-stub'. + + * progmodes/gdb-mi.el (gdb): Fix typo in previous change. + +2011-03-22 Juanma Barranquero <lekktu@gmail.com> + + * emacs-lisp/derived.el (define-derived-mode): Wrap declaration of + keymap variable in `with-no-warnings' to avoid a warning when the + keymap has been already `defconst'ed. + +2011-03-22 Leo Liu <sdl.web@gmail.com> + + * abbrev.el (write-abbrev-file): Use utf-8 for writing if it can + encode all chars in abbrevs; otherwise use emacs-mule or + utf-8-emacs. (Bug#8308) + +2011-03-22 Juanma Barranquero <lekktu@gmail.com> + + * simple.el (backward-delete-char-untabify): + Avoid warning about using `delete-backward-char'. + + * image.el (image-type-file-name-regexps): Make it variable. + `imagemagick-register-types' modifies it, and the user may want + to add new extensions for known image types. + (imagemagick-register-types): Throw error if not using ImageMagick. + +2011-03-22 Leo Liu <sdl.web@gmail.com> + + * net/rcirc.el (rcirc-completion-at-point): Return nil if point is + located before rcirc-prompt-end-marker. + (rcirc-complete): Error if point is not after rcirc prompt. + Handle the case when table is nil. + (rcirc-user-authenticated): Define to fix compiler warning. + +2011-03-22 Chong Yidong <cyd@stupidchicken.com> + + * custom.el (custom--inhibit-theme-enable): Make it affect only + custom-theme-set-variables and custom-theme-set-faces. + (provide-theme): Ignore custom--inhibit-theme-enable. + (load-theme): Enable the theme explicitly if NO-ENABLE is non-nil. + (custom-enabling-themes): Delete variable. + (enable-theme): Accept only loaded themes as arguments. + Ignore the special custom-enabled-themes variable. + (custom-enabled-themes): Forbid themes from setting this. + Eliminate use of custom-enabling-themes. + (custom-push-theme): Quote "changed" custom var entry. + +2011-03-21 Leo Liu <sdl.web@gmail.com> + + * ido.el (ido-read-internal): Add ido-selected to history instead + of user input. + +2011-03-21 Stefan Monnier <monnier@iro.umontreal.ca> + + * subr.el (deferred-action-list, deferred-action-function): + Mark obsolete. + +2011-03-21 Leo Liu <sdl.web@gmail.com> + + * vc/log-view.el: Remove (require 'wid-edit), not needed after the + change on 2011-02-13 (bug#8309). + + * minibuffer.el (read-file-name-function): Change default value. + (read-file-name--defaults): Rename from read-file-name-defaults. + (read-file-name-default): Rename from read-file-name. + (read-file-name): Call read-file-name-function. + 2011-03-21 Glenn Morris <rgm@gnu.org> * eshell/esh-opt.el (eshell-eval-using-options, eshell-process-args): @@ -310,8 +461,8 @@ 2011-03-09 Michael Albinus <michael.albinus@gmx.de> - * net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band): Do - not use `tramp-file-name-port', because this returns also + * net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band): + Do not use `tramp-file-name-port', because this returns also `tramp-default-port'. 2011-03-09 Deniz Dogan <deniz.a.m.dogan@gmail.com> @@ -340,8 +491,8 @@ * emacs-lisp/package.el (package-tar-file-info): Handle also remote files. - * emacs-lisp/package-x.el (package-upload-buffer-internal): Use - `equal' for upload base check. + * emacs-lisp/package-x.el (package-upload-buffer-internal): + Use `equal' for upload base check. 2011-03-08 Arni Magnusson <arnima@hafro.is> (tiny change) @@ -670,9 +821,9 @@ 2011-03-03 Christian Ohler <ohler@gnu.org> * emacs-lisp/ert.el (ert--explain-equal): New function. - (ert--explain-equal-rec): Renamed from `ert--explain-not-equal'. + (ert--explain-equal-rec): Rename from `ert--explain-not-equal'. All callers changed. - (ert--explain-equal-including-properties): Renamed from + (ert--explain-equal-including-properties): Rename from `ert--explain-not-equal-including-properties'. All callers changed. @@ -8195,8 +8346,8 @@ Sync with Tramp 2.1.19. - * net/tramp-gvfs.el (tramp-gvfs-handle-write-region): Protect - deleting tmpfile. + * net/tramp-gvfs.el (tramp-gvfs-handle-write-region): + Protect deleting tmpfile. (tramp-gvfs-maybe-open-connection): Use `tramp-compat-funcall'. * net/tramp.el (tramp-handle-expand-file-name) @@ -10474,8 +10625,8 @@ * net/tramp-ftp.el (tramp-ftp-file-name-handler): Use `delete-file' instead of `tramp-compat-delete-file'. - * net/tramp-gvfs.el (tramp-gvfs-handle-write-region): Use - `delete-file' instead of `tramp-compat-delete-file'. + * net/tramp-gvfs.el (tramp-gvfs-handle-write-region): + Use `delete-file' instead of `tramp-compat-delete-file'. * net/tramp-imap.el (tramp-imap-do-copy-or-rename-file): Use `delete-file' instead of `tramp-compat-delete-file'. diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 3844391a180..b2cd2064da2 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -65,7 +65,8 @@ abbreviation causes it to expand and be replaced by its expansion." (defvar edit-abbrevs-map (let ((map (make-sparse-keymap))) - (define-key map "\C-x\C-s" 'edit-abbrevs-redefine) + (define-key map "\C-x\C-s" 'abbrev-edit-save-buffer) + (define-key map "\C-x\C-w" 'abbrev-edit-save-to-file) (define-key map "\C-c\C-c" 'edit-abbrevs-redefine) map) "Keymap used in `edit-abbrevs'.") @@ -123,8 +124,13 @@ Otherwise display all abbrevs." (if local (insert-abbrev-table-description (abbrev-table-name local-table) t) - (dolist (table abbrev-table-name-list) - (insert-abbrev-table-description table t))) + (let (empty-tables) + (dolist (table abbrev-table-name-list) + (if (abbrev-table-empty-p (symbol-value table)) + (push table empty-tables) + (insert-abbrev-table-description table t))) + (dolist (table (nreverse empty-tables)) + (insert-abbrev-table-description table t)))) (goto-char (point-min)) (set-buffer-modified-p nil) (edit-abbrevs-mode) @@ -211,13 +217,15 @@ Does not display any message." ;(interactive "fRead abbrev file: ") (read-abbrev-file file t)) -(defun write-abbrev-file (&optional file) +(defun write-abbrev-file (&optional file verbose) "Write all user-level abbrev definitions to a file of Lisp code. This does not include system abbrevs; it includes only the abbrev tables listed in listed in `abbrev-table-name-list'. The file written can be loaded in another session to define the same abbrevs. The argument FILE is the file name to write. If omitted or nil, the file -specified in `abbrev-file-name' is used." +specified in `abbrev-file-name' is used. +If VERBOSE is non-nil, display a message indicating where abbrevs +have been saved." (interactive (list (read-file-name "Write abbrev file: " @@ -225,21 +233,47 @@ specified in `abbrev-file-name' is used." abbrev-file-name))) (or (and file (> (length file) 0)) (setq file abbrev-file-name)) - (let ((coding-system-for-write 'emacs-mule)) - (with-temp-file file - (insert ";;-*-coding: emacs-mule;-*-\n") + (let ((coding-system-for-write 'utf-8)) + (with-temp-buffer (dolist (table - ;; We sort the table in order to ease the automatic - ;; merging of different versions of the user's abbrevs - ;; file. This is useful, for example, for when the - ;; user keeps their home directory in a revision - ;; control system, and is therefore keeping multiple - ;; slightly-differing copies loosely synchronized. - (sort (copy-sequence abbrev-table-name-list) - (lambda (s1 s2) - (string< (symbol-name s1) - (symbol-name s2))))) - (insert-abbrev-table-description table nil))))) + ;; We sort the table in order to ease the automatic + ;; merging of different versions of the user's abbrevs + ;; file. This is useful, for example, for when the + ;; user keeps their home directory in a revision + ;; control system, and is therefore keeping multiple + ;; slightly-differing copies loosely synchronized. + (sort (copy-sequence abbrev-table-name-list) + (lambda (s1 s2) + (string< (symbol-name s1) + (symbol-name s2))))) + (insert-abbrev-table-description table nil)) + (when (unencodable-char-position (point-min) (point-max) 'utf-8) + (setq coding-system-for-write + (if (> emacs-major-version 24) + 'utf-8-emacs + ;; For compatibility with Emacs 22 (See Bug#8308) + 'emacs-mule))) + (goto-char (point-min)) + (insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write)) + (write-region nil nil file nil (and (not verbose) 0))))) + +(defun abbrev-edit-save-to-file (file) + "Save all user-level abbrev definitions in current buffer to FILE." + (interactive + (list (read-file-name "Save abbrevs to file: " + (file-name-directory + (expand-file-name abbrev-file-name)) + abbrev-file-name))) + (edit-abbrevs-redefine) + (write-abbrev-file file t)) + +(defun abbrev-edit-save-buffer () + "Save all user-level abbrev definitions in current buffer. +The saved abbrevs are written to the file specified by +`abbrev-file-name'." + (interactive) + (abbrev-edit-save-to-file abbrev-file-name)) + (defun add-mode-abbrev (arg) "Define mode-specific abbrev for last word(s) before point. @@ -412,6 +446,19 @@ PROPS is a list of properties." (and (vectorp object) (numberp (abbrev-table-get object :abbrev-table-modiff)))) +(defun abbrev-table-empty-p (object &optional ignore-system) + "Return nil if there are no abbrev symbols in OBJECT. +If IGNORE-SYSTEM is non-nil, system definitions are ignored." + (unless (abbrev-table-p object) + (error "Non abbrev table object")) + (not (catch 'some + (mapatoms (lambda (abbrev) + (unless (or (zerop (length (symbol-name abbrev))) + (and ignore-system + (abbrev-get abbrev :system))) + (throw 'some t))) + object)))) + (defvar global-abbrev-table (make-abbrev-table) "The abbrev table whose abbrevs affect all buffers. Each buffer may also have a local abbrev table. diff --git a/lisp/allout-widgets.el b/lisp/allout-widgets.el index 47f181ab76b..ae4265bda1f 100644 --- a/lisp/allout-widgets.el +++ b/lisp/allout-widgets.el @@ -238,7 +238,7 @@ buffer, and tracking increases as new widgets are added and decreases as obsolete widgets are garbage collected." :type 'boolean :group 'allout-widgets-developer) -(defvar allout-widgets-tally (make-hash-table :test 'eq :weakness 'key) +(defvar allout-widgets-tally nil "Hash-table of existing allout widgets, for debugging. Table is maintained iff `allout-widgets-maintain-tally' is non-nil. @@ -2100,6 +2100,7 @@ previously established or is not moved." (cond ((not overlay) (when start (setq overlay (make-overlay start end nil t nil)) (overlay-put overlay 'button item-widget) + (overlay-put overlay 'evaporate t) (widget-put item-widget :span-overlay overlay) t)) ;; report: @@ -2343,6 +2344,19 @@ The elements of LIST are not copied, just the list structure itself." (while (consp list) (push (pop list) res)) (prog1 (nreverse res) (setcdr res list))) (car list))) +;;;_ . allout-widgets-count-buttons-in-region (start end) +(defun allout-widgets-count-buttons-in-region (start end) + "Debugging/diagnostic tool - count overlays with 'button' property in region." + (interactive "r") + (setq start (or start (point-min)) + end (or end (point-max))) + (if (> start end) (let ((interim start)) (setq start end end interim))) + (let ((button-overlays (delq nil + (mapcar (function (lambda (o) + (if (overlay-get o 'button) + o))) + (overlays-in start end))))) + (length button-overlays))) ;;;_ : Run unit tests: (defun allout-widgets-run-unit-tests () diff --git a/lisp/allout.el b/lisp/allout.el index 3fb8ed7ccd5..736ec42718b 100644 --- a/lisp/allout.el +++ b/lisp/allout.el @@ -4489,8 +4489,9 @@ Topic exposure is marked with text-properties, to be used by ;; advance to just after end of this annotation: (setq next (allout-next-single-char-property-change (point) 'allout-was-hidden nil end)) - (overlay-put (make-overlay prev next nil 'front-advance) - 'category 'allout-exposure-category) + (let ((o (make-overlay prev next nil 'front-advance))) + (overlay-put o 'category 'allout-exposure-category) + (overlay-put o 'evaporate t)) (allout-deannotate-hidden prev next) (setq prev next) (if next (goto-char next))))) diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el index 2b43940c1bd..ff7edf40dcb 100644 --- a/lisp/ansi-color.el +++ b/lisp/ansi-color.el @@ -132,8 +132,18 @@ Parameter Color 37 47 white This vector is used by `ansi-color-make-color-map' to create a color -map. This color map is stored in the variable `ansi-color-map'." - :type '(vector string string string string string string string string) +map. This color map is stored in the variable `ansi-color-map'. + +Each element may also be a cons cell where the car and cdr specify the +foreground and background colors, respectively." + :type '(vector (choice color (cons color color)) + (choice color (cons color color)) + (choice color (cons color color)) + (choice color (cons color color)) + (choice color (cons color color)) + (choice color (cons color color)) + (choice color (cons color color)) + (choice color (cons color color))) :set 'ansi-color-map-update :initialize 'custom-initialize-default :group 'ansi-colors) @@ -528,7 +538,8 @@ The face definitions are based upon the variables (mapc (function (lambda (e) (aset ansi-color-map index - (ansi-color-make-face 'foreground e)) + (ansi-color-make-face 'foreground + (if (consp e) (car e) e))) (setq index (1+ index)) )) ansi-color-names-vector) ;; background attributes @@ -536,7 +547,8 @@ The face definitions are based upon the variables (mapc (function (lambda (e) (aset ansi-color-map index - (ansi-color-make-face 'background e)) + (ansi-color-make-face 'background + (if (consp e) (cdr e) e))) (setq index (1+ index)) )) ansi-color-names-vector) ansi-color-map)) diff --git a/lisp/comint.el b/lisp/comint.el index 711ebce20a3..c9d2108f132 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -368,7 +368,7 @@ text matching `comint-prompt-regexp', depending on the value of (defvar comint-dynamic-complete-functions '(comint-replace-by-expanded-history comint-dynamic-complete-filename) "List of functions called to perform completion. -Functions should return non-nil if completion was performed. +Works like `completion-at-point-functions'. See also `comint-dynamic-complete'. This is a good thing to set in mode hooks.") @@ -1008,7 +1008,6 @@ See also `comint-read-input-ring'." (message "No history") (let ((history nil) (history-buffer " *Input History*") - (index (1- (ring-length comint-input-ring))) (conf (current-window-configuration))) ;; We have to build up a list ourselves from the ring vector. (dotimes (index (ring-length comint-input-ring)) @@ -2946,13 +2945,22 @@ interpreter (e.g., the percent notation of cmd.exe on NT)." (setq name (replace-match env-var-val t t name)))))) name)) +(defun comint--match-partial-filename () + "Return the filename at point as-is, or nil if none is found. +See `comint-word'." + (comint-word comint-file-name-chars)) + +(defun comint--unquote&expand-filename (filename) + ;; FIXME: The code below does unquote-then-expand which means that "\\$HOME" + ;; gets expanded to the same as "$HOME" + (comint-substitute-in-file-name + (comint-unquote-filename filename))) + (defun comint-match-partial-filename () - "Return the filename at point, or nil if none is found. + "Return the unquoted&expanded filename at point, or nil if none is found. Environment variables are substituted. See `comint-word'." - (let ((filename (comint-word comint-file-name-chars))) - (and filename (comint-substitute-in-file-name - (comint-unquote-filename filename))))) - + (let ((filename (comint--match-partial-filename))) + (and filename (comint--unquote&expand-filename filename)))) (defun comint-quote-filename (filename) "Return FILENAME with magic characters quoted. @@ -2987,13 +2995,13 @@ Calls the functions in `comint-dynamic-complete-functions' to perform completion until a function returns non-nil, at which point completion is assumed to have occurred." (interactive) - (run-hook-with-args-until-success 'comint-dynamic-complete-functions)) + (let ((completion-at-point-functions comint-dynamic-complete-functions)) + (completion-at-point))) (defun comint-dynamic-complete-filename () "Dynamically complete the filename at point. -Completes if after a filename. See `comint-match-partial-filename' and -`comint-dynamic-complete-as-filename'. +Completes if after a filename. This function is similar to `comint-replace-by-expanded-filename', except that it won't change parts of the filename already entered in the buffer; it just adds completion characters to the end of the filename. A completions listing @@ -3005,7 +3013,7 @@ completions listing is dependent on the value of `comint-completion-autolist'. Returns t if successful." (interactive) - (when (comint-match-partial-filename) + (when (comint--match-partial-filename) (unless (window-minibuffer-p (selected-window)) (message "Completing file name...")) (comint-dynamic-complete-as-filename))) @@ -3021,18 +3029,12 @@ See `comint-dynamic-complete-filename'. Returns t if successful." ;;(file-name-handler-alist nil) (minibuffer-p (window-minibuffer-p (selected-window))) (success t) - (dirsuffix (cond ((not comint-completion-addsuffix) - "") - ((not (consp comint-completion-addsuffix)) - "/") - (t - (car comint-completion-addsuffix)))) - (filesuffix (cond ((not comint-completion-addsuffix) - "") - ((not (consp comint-completion-addsuffix)) - " ") - (t - (cdr comint-completion-addsuffix)))) + (dirsuffix (cond ((not comint-completion-addsuffix) "") + ((not (consp comint-completion-addsuffix)) "/") + (t (car comint-completion-addsuffix)))) + (filesuffix (cond ((not comint-completion-addsuffix) "") + ((not (consp comint-completion-addsuffix)) " ") + (t (cdr comint-completion-addsuffix)))) (filename (comint-match-partial-filename)) (filename-beg (if filename (match-beginning 0) (point))) (filename-end (if filename (match-end 0) (point))) diff --git a/lisp/cus-start.el b/lisp/cus-start.el index 788731e4dbc..1188d37150a 100644 --- a/lisp/cus-start.el +++ b/lisp/cus-start.el @@ -356,6 +356,7 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of (const alt) (const hyper) (const super)) "23.1") (ns-antialias-text ns boolean "23.1") + (ns-auto-hide-menu-bar ns boolean "24.0") ;; process.c (delete-exited-processes processes-basics boolean) ;; syntax.c diff --git a/lisp/custom.el b/lisp/custom.el index d9bb4f954bc..5b5592698d8 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -852,10 +852,10 @@ See `custom-known-themes' for a list of known themes." ;; theme is later disabled. (cond ((and (eq prop 'theme-value) (boundp symbol)) - (let ((sv (get symbol 'standard-value))) - (unless (and sv - (equal (eval (car sv)) (symbol-value symbol))) - (setq old (list (list 'changed (symbol-value symbol))))))) + (let ((sv (get symbol 'standard-value)) + (val (symbol-value symbol))) + (unless (and sv (equal (eval (car sv)) val)) + (setq old `((changed ,(custom-quote val))))))) ((and (facep symbol) (not (face-attr-match-p symbol @@ -1084,10 +1084,10 @@ name." :version "24.1") (defvar custom--inhibit-theme-enable nil - "If non-nil, loading a theme does not enable it. -This internal variable is set by `load-theme' when its NO-ENABLE -argument is non-nil, and it affects `custom-theme-set-variables', -`custom-theme-set-faces', and `provide-theme'." ) + "Whether the custom-theme-set-* functions act immediately. +If nil, `custom-theme-set-variables' and `custom-theme-set-faces' +change the current values of the given variable or face. If +non-nil, they just make a record of the theme settings.") (defun provide-theme (theme) "Indicate that this file provides THEME. @@ -1097,15 +1097,7 @@ property `theme-feature' (which is usually a symbol created by (unless (custom-theme-name-valid-p theme) (error "Custom theme cannot be named %S" theme)) (custom-check-theme theme) - (provide (get theme 'theme-feature)) - (unless custom--inhibit-theme-enable - ;; By default, loading a theme also enables it. - (push theme custom-enabled-themes) - ;; `user' must always be the highest-precedence enabled theme. - ;; Make that remain true. (This has the effect of making user - ;; settings override the ones just loaded, too.) - (let ((custom-enabling-themes t)) - (enable-theme 'user)))) + (provide (get theme 'theme-feature))) (defcustom custom-safe-themes '(default) "List of themes that are considered safe to load. @@ -1157,9 +1149,11 @@ Return t if THEME was successfully loaded, nil otherwise." (expand-file-name "themes/" data-directory))) (member hash custom-safe-themes) (custom-theme-load-confirm hash)) - (let ((custom--inhibit-theme-enable no-enable)) - (eval-buffer) - t))))) + (let ((custom--inhibit-theme-enable t)) + (eval-buffer)) + (unless no-enable + (enable-theme theme)) + t)))) (defun custom-theme-load-confirm (hash) "Query the user about loading a Custom theme that may not be safe. @@ -1238,68 +1232,70 @@ NAME should be a symbol." ;;; Enabling and disabling loaded themes. -(defvar custom-enabling-themes nil) - (defun enable-theme (theme) "Reenable all variable and face settings defined by THEME. -The newly enabled theme gets the highest precedence (after `user'). -If it is already enabled, just give it highest precedence (after `user'). - -If THEME does not specify any theme settings, this tries to load -the theme from its theme file, by calling `load-theme'." +THEME should be either `user', or a theme loaded via `load-theme'. +After this function completes, THEME will have the highest +precedence (after `user')." (interactive (list (intern (completing-read "Enable custom theme: " - obarray (lambda (sym) (get sym 'theme-settings)))))) + obarray (lambda (sym) (get sym 'theme-settings)) t)))) (if (not (custom-theme-p theme)) - (load-theme theme) - ;; This could use a bit of optimization -- cyd - (let ((settings (get theme 'theme-settings))) - (dolist (s settings) - (let* ((prop (car s)) - (symbol (cadr s)) - (spec-list (get symbol prop))) - (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list))) - (if (eq prop 'theme-value) - (custom-theme-recalc-variable symbol) - (custom-theme-recalc-face symbol))))) - (unless (eq theme 'user) - (setq custom-enabled-themes - (cons theme (delq theme custom-enabled-themes))) - (unless custom-enabling-themes - (enable-theme 'user))))) + (error "Undefined Custom theme %s" theme)) + (let ((settings (get theme 'theme-settings))) + ;; Loop through theme settings, recalculating vars/faces. + (dolist (s settings) + (let* ((prop (car s)) + (symbol (cadr s)) + (spec-list (get symbol prop))) + (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list))) + (cond + ((eq prop 'theme-face) + (custom-theme-recalc-face symbol)) + ((eq prop 'theme-value) + ;; Don't change `custom-enabled-themes'; that's special. + (unless (eq symbol 'custom-enabled-themes) + (custom-theme-recalc-variable symbol))))))) + (unless (eq theme 'user) + (setq custom-enabled-themes + (cons theme (delq theme custom-enabled-themes))) + ;; Give the `user' theme the highest priority. + (enable-theme 'user))) (defcustom custom-enabled-themes nil "List of enabled Custom Themes, highest precedence first. +This list does not include the `user' theme, which is set by +Customize and always takes precedence over other Custom Themes. -This does not include the `user' theme, which is set by Customize, -and always takes precedence over other Custom Themes." +This variable cannot be defined inside a Custom theme; there, it +is simply ignored." :group 'customize :type '(repeat symbol) :set-after '(custom-theme-directory custom-theme-load-path custom-safe-themes) :risky t :set (lambda (symbol themes) - ;; Avoid an infinite loop when custom-enabled-themes is - ;; defined in a theme (e.g. `user'). Enabling the theme sets - ;; custom-enabled-themes, which enables the theme... - (unless custom-enabling-themes - (let ((custom-enabling-themes t) failures) - (setq themes (delq 'user (delete-dups themes))) - (if (boundp symbol) - (dolist (theme (symbol-value symbol)) - (if (not (memq theme themes)) - (disable-theme theme)))) - (dolist (theme (reverse themes)) - (condition-case nil - (enable-theme theme) - (error (progn (push theme failures) - (setq themes (delq theme themes)))))) - (enable-theme 'user) - (custom-set-default symbol themes) - (if failures - (message "Failed to enable themes: %s" - (mapconcat 'symbol-name failures " "))))))) + (let (failures) + (setq themes (delq 'user (delete-dups themes))) + ;; Disable all themes not in THEMES. + (if (boundp symbol) + (dolist (theme (symbol-value symbol)) + (if (not (memq theme themes)) + (disable-theme theme)))) + ;; Call `enable-theme' or `load-theme' on each of THEMES. + (dolist (theme (reverse themes)) + (condition-case nil + (if (custom-theme-p theme) + (enable-theme theme) + (load-theme theme)) + (error (setq failures (cons theme failures) + themes (delq theme themes))))) + (enable-theme 'user) + (custom-set-default symbol themes) + (if failures + (message "Failed to enable theme: %s" + (mapconcat 'symbol-name failures ", ")))))) (defsubst custom-theme-enabled-p (theme) "Return non-nil if THEME is enabled." diff --git a/lisp/emacs-lisp/derived.el b/lisp/emacs-lisp/derived.el index 425a77ee77f..1db98ac39c8 100644 --- a/lisp/emacs-lisp/derived.el +++ b/lisp/emacs-lisp/derived.el @@ -201,7 +201,7 @@ No problems result if this variable is not bound. name)))) (unless (boundp ',map) (put ',map 'definition-name ',child)) - (defvar ,map (make-sparse-keymap)) + (with-no-warnings (defvar ,map (make-sparse-keymap))) (unless (get ',map 'variable-documentation) (put ',map 'variable-documentation (purecopy ,(format "Keymap for `%s'." child)))) diff --git a/lisp/eshell/esh-opt.el b/lisp/eshell/esh-opt.el index a9e8f11c39a..91d3cac198a 100644 --- a/lisp/eshell/esh-opt.el +++ b/lisp/eshell/esh-opt.el @@ -102,10 +102,9 @@ interned variable `args' (created using a `let' form)." macro-args (list 'eshell-stringify-list (list 'eshell-flatten-list macro-args))))) - (let ,(append (mapcar (lambda (opt) - (or (and (listp opt) (nth 3 opt)) - 'eshell-option-stub)) - (cadr options)) + (let ,(append (delq nil (mapcar (lambda (opt) + (and (listp opt) (nth 3 opt))) + (cadr options))) '(usage-msg last-value ext-command args)) (eshell-do-opt ,name ,options (quote ,body-forms))))) diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 7eca03bd93b..51169f7b9df 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,137 @@ +2011-03-30 Chong Yidong <cyd@stupidchicken.com> + + * proto-stream.el (open-protocol-stream): Bring back `network' type. + Make this the default type. + (proto-stream-open-plain): Rename from proto-stream-open-default. + (open-protocol-stream, proto-stream-open-starttls) + (proto-stream-open-tls, proto-stream-open-shell): Replace `default' + with `plain'. + + * nnimap.el (nnimap-stream, nnimap-open-connection-1): Accept `network' + value. + + * nntp.el (nntp-open-connection-function): Document the fact that some + values are not functions but are instead handled specially. Recognize + nntp-open-plain-stream value. + (nntp-open-connection): Recognize that value. + +2011-03-29 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * gssapi.el (open-gssapi-stream): Remove the last mentions of the IMAP + stuff. + + * gnus-score.el (gnus-score-string): Fix calling convention of + `gnus-simplify-buffer-fuzzy' after last patches. + + * gnus-sum.el (gnus-update-marks): Don't send any marks updates to the + server for articles we didn't get any headers for. This is a sanity + check. + +2011-03-29 Michael Welsh Duggan <md5i@md5i.com> + + * nnimap.el (nnimap-open-connection-1): Is the login responds with a + new CAPABILITY, use it. + +2011-03-29 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * gnus-agent.el (gnus-agent-fetch-headers): Don't message if we're not + downloading anything. + + * gnus.el (gnus-splash-svg-color-symbols): Removed superfluous `and'. + +2011-03-29 Adam Sjøgren <asjo@koldfront.dk> + + * gnus.el (gnus-group-startup-message): Prefer svg file and replace + colors. + (gnus-splash-svg-color-symbols): New function. + +2011-03-29 Lars Magne Ingebrigtsen <larsi@gnus.org> + + * gnus-sum.el (gnus-simplify-buffer-fuzzy): Take the regexp explicitly + instead of using the global gnus-simplify-subject-fuzzy-regexp. + (gnus-simplify-subject-fuzzy): Use the local + gnus-simplify-subject-fuzzy-regex instead of the global one. This + makes using this variable in group parameters work. + +2011-03-29 Teodor Zlatanov <tzz@lifelogs.com> + + * gnus-registry.el (gnus-registry-unfollowed-groups): Add + "archive:sent" to the unfollowed group regex (for the recent Gnus + archive:sent-YYYY-MM-DD groups). + (gnus-registry-split-fancy-with-parent): Bail out early in sender + tracking if there are more than `gnus-registry-max-track-groups' + matches. + +2011-03-29 Stefan Monnier <monnier@iro.umontreal.ca> + + * message.el (message--yank-original-internal): New function to do the + insertion cleanly inside eval in `message-yank-original'. + (message-yank-original): Use it. + +2011-03-29 Julien Danjou <julien@danjou.info> + + * mm-view.el (mm-display-inline-fontify): Use `set-normal-mode' with + local variables disabled rather than `normal-mode'. + +2011-03-26 Chong Yidong <cyd@stupidchicken.com> + + * proto-stream.el: Changes preparatory to merging open-protocol-stream + with open-network-stream. + (proto-stream-always-use-starttls): Option removed. + (open-protocol-stream): Return a process object by default. Provide a + new parameter :return-list specifying a list-type return value, which + now has the form (PROP . PLIST) instead of a fixed-length list. Change + :type `network' to `try-starttls', and `network-only' to `default'. + Make `default' the default, for compatibility with open-network-stream. + Handle the no-parameter case exactly as open-network-stream, with no + additional stream processing. Search plists using plist-get. + Explicitly add :end-of-commend parameter if it is missing. + (proto-stream-open-default): Renamed from + proto-stream-open-network-only. Return 'default as the type. + (proto-stream-open-starttls): Rename from proto-stream-open-network. + Use plist-get. Don't return `tls' as the type if STARTTLS negotiation + failed. Always return a list with a (possibly dead) process as the + first element, for compatibility with open-network-stream. + (proto-stream-open-tls): Use plist-get. Always return a list. + (proto-stream-open-shell): Return `default' as connection type. + (proto-stream-capability-open): Use plist-get. + (proto-stream-eoc): Function deleted. + + * nnimap.el (nnimap-stream, nnimap-open-connection) + (nnimap-open-connection-1): Handle renaming of :type parameter for + open-protocol-stream. + (nnimap-open-connection-1): Pass a :return-list parameter + open-protocol-stream to obtain a list return value. Parse this list + using plist-get. + + * nntp.el (nntp-open-connection): Handle renaming of :type parameter + for open-protocol-stream. Accept open-protocol-stream return value + that is a subprocess object instead of a list. Handle the case of a + dead returned process. + +2011-03-25 Teodor Zlatanov <tzz@lifelogs.com> + + * mm-util.el (mm-handle-filename): Move to mm-decode.el (bug#8330). + + * mm-decode.el (mm-handle-filename): Move from mm-util.el (bug#8330). + +2011-03-21 Julien Danjou <julien@danjou.info> + + * mm-view.el (mm-display-inline-fontify): Make mode optional, and call + normal-mode if not set. Set temp buffer unmodified to avoid kill-buffer + query. + (mm-inline-text): Render normal text with fontification whenever + possible. + + * gnus-sum.el (gnus-summary-save-parts-1): + * gnus-art.el (gnus-article-browse-html-save-cid-content) + (gnus-article-browse-html-parts, gnus-mime-delete-part) + (gnus-mime-copy-part, gnus-mime-inline-part, gnus-insert-mime-button): + Use `mm-handle-filename'. + + * mm-util.el (mm-handle-filename): New function, return the filename of + an handle. + 2011-03-18 Julien Danjou <julien@danjou.info> * gnus-util.el (gnus-buffer-live-p): Simplify gnus-buffer-live-p. diff --git a/lisp/gnus/gnus-agent.el b/lisp/gnus/gnus-agent.el index 989488c0995..52fbe9da11f 100644 --- a/lisp/gnus/gnus-agent.el +++ b/lisp/gnus/gnus-agent.el @@ -1925,9 +1925,10 @@ article numbers will be returned." (setq articles (gnus-list-range-intersection articles (list (cons low high))))))) - (gnus-message - 10 "gnus-agent-fetch-headers: undownloaded articles are '%s'" - (gnus-compress-sequence articles t)) + (when articles + (gnus-message + 10 "gnus-agent-fetch-headers: undownloaded articles are '%s'" + (gnus-compress-sequence articles t))) (with-current-buffer nntp-server-buffer (if articles diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 7c7e0531926..97677988f0a 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -2811,14 +2811,11 @@ Return file name." ((equal (concat "<" cid ">") (mm-handle-id handle)) (setq file (expand-file-name - (or (mail-content-type-get - (mm-handle-disposition handle) 'filename) - (mail-content-type-get - (setq type (mm-handle-type handle)) 'name) - (concat - (make-temp-name "cid") - (car (rassoc (car type) mailcap-mime-extensions)))) - directory)) + (or (mm-handle-filename handle) + (concat + (make-temp-name "cid") + (car (rassoc (car (mm-handle-type handle)) mailcap-mime-extensions)))) + directory)) (mm-save-part-to-file handle file) (throw 'found file)))))))) @@ -2835,10 +2832,7 @@ message header will be added to the bodies of the \"text/html\" parts." ((or (equal (car (setq type (mm-handle-type handle))) "text/html") (and (equal (car type) "message/external-body") (or header - (setq file (or (mail-content-type-get type 'name) - (mail-content-type-get - (mm-handle-disposition handle) - 'filename)))) + (setq file (mm-handle-filename handle))) (or (mm-handle-cache handle) (condition-case code (progn (mm-extern-cache-contents handle) t) @@ -5043,14 +5037,11 @@ Deleting parts may malfunction or destroy the article; continue? ")) (let* ((data (get-text-property (point) 'gnus-data)) (id (get-text-property (point) 'gnus-part)) (handles gnus-article-mime-handles) - (none "(none)") (description (let ((desc (mm-handle-description data))) (when desc (mail-decode-encoded-word-string desc)))) - (filename - (or (mail-content-type-get (mm-handle-disposition data) 'filename) - none)) + (filename (or (mm-handle-filename (mm-handle-disposition data)) "(none)")) (type (mm-handle-media-type data))) (unless data (error "No MIME part under point")) @@ -5168,10 +5159,7 @@ are decompressed." (unless handle (setq handle (get-text-property (point) 'gnus-data))) (when handle - (let ((filename (or (mail-content-type-get (mm-handle-type handle) - 'name) - (mail-content-type-get (mm-handle-disposition handle) - 'filename))) + (let ((filename (mm-handle-filename handle)) contents dont-decode charset coding-system) (mm-with-unibyte-buffer (mm-insert-part handle) @@ -5261,12 +5249,7 @@ Compressed files like .gz and .bz2 are decompressed." (mm-with-unibyte-buffer (mm-insert-part handle) (setq contents - (or (mm-decompress-buffer - (or (mail-content-type-get (mm-handle-type handle) - 'name) - (mail-content-type-get (mm-handle-disposition handle) - 'filename)) - nil t) + (or (mm-decompress-buffer (mm-handle-filename handle) nil t) (buffer-string)))) (cond ((not arg) @@ -5671,8 +5654,7 @@ all parts." (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed) (let ((gnus-tmp-name - (or (mail-content-type-get (mm-handle-type handle) 'name) - (mail-content-type-get (mm-handle-disposition handle) 'filename) + (or (mm-handle-filename handle) (mail-content-type-get (mm-handle-type handle) 'url) "")) (gnus-tmp-type (mm-handle-media-type handle)) diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index cef173ce1ec..db3cc06e9aa 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el @@ -124,7 +124,7 @@ display." :type 'symbol) (defcustom gnus-registry-unfollowed-groups - '("delayed$" "drafts$" "queue$" "INBOX$" "^nnmairix:") + '("delayed$" "drafts$" "queue$" "INBOX$" "^nnmairix:" "archive") "List of groups that gnus-registry-split-fancy-with-parent won't return. The group names are matched, they don't have to be fully qualified. This parameter tells the Registry 'never split a @@ -541,24 +541,26 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." user-mail-address))) (maphash (lambda (key value) - (let ((this-sender (cdr - (gnus-registry-fetch-extra key 'sender))) - matches) - (when (and this-sender - (equal sender this-sender)) - (let ((groups (gnus-registry-fetch-groups - key - gnus-registry-max-track-groups))) - (dolist (group groups) - (when (and group (gnus-registry-follow-group-p group)) - (push group found-full) - (setq found (append (list group) (delete group found)))))) - (push key matches) - (gnus-message - ;; raise level of messaging if gnus-registry-track-extra - (if gnus-registry-track-extra 7 9) - "%s (extra tracking) traced sender %s to groups %s (keys %s)" - log-agent sender found matches)))) + ;; don't use more than gnus-registry-max-track-groups + (when (< (length found-full) gnus-registry-max-track-groups) + (let ((this-sender + (cdr (gnus-registry-fetch-extra key 'sender))) + matches) + (when (and this-sender + (equal sender this-sender)) + (let ((groups (gnus-registry-fetch-groups + key + gnus-registry-max-track-groups))) + (dolist (group groups) + (when (and group (gnus-registry-follow-group-p group)) + (push group found-full) + (setq found (append (list group) (delete group found)))))) + (push key matches) + (gnus-message + ;; raise level of messaging if gnus-registry-track-extra + (if gnus-registry-track-extra 7 9) + "%s (extra tracking) traced sender %s to groups %s (keys %s)" + log-agent sender found matches))))) gnus-registry-hashtb) ;; filter the found groups and return them ;; the found groups are NOT the full groups diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el index e376b7a7b6e..9bbfbfb057e 100644 --- a/lisp/gnus/gnus-score.el +++ b/lisp/gnus/gnus-score.el @@ -2151,7 +2151,7 @@ score in `gnus-newsgroup-scored' by SCORE." ;; Find fuzzy matches. (when fuzzies ;; Simplify the entire buffer for easy matching. - (gnus-simplify-buffer-fuzzy) + (gnus-simplify-buffer-fuzzy gnus-simplify-subject-fuzzy-regexp) (while (setq kill (cadaar fuzzies)) (let* ((match (nth 0 kill)) (type (nth 3 kill)) diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 29a98b7d11d..91dc6fb9595 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -1734,7 +1734,7 @@ If RE-ONLY is non-nil, strip leading `Re:'s only." (while (re-search-forward regexp nil t) (replace-match (or newtext "")))) -(defun gnus-simplify-buffer-fuzzy () +(defun gnus-simplify-buffer-fuzzy (regexp) "Simplify string in the buffer fuzzily. The string in the accessible portion of the current buffer is simplified. It is assumed to be a single-line subject. @@ -1748,11 +1748,10 @@ matter is removed. Additional things can be deleted by setting (while (not (eq modified-tick (buffer-modified-tick))) (setq modified-tick (buffer-modified-tick)) (cond - ((listp gnus-simplify-subject-fuzzy-regexp) - (mapc 'gnus-simplify-buffer-fuzzy-step - gnus-simplify-subject-fuzzy-regexp)) - (gnus-simplify-subject-fuzzy-regexp - (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp))) + ((listp regexp) + (mapc 'gnus-simplify-buffer-fuzzy-step regexp)) + (regexp + (gnus-simplify-buffer-fuzzy-step regexp))) (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *") (gnus-simplify-buffer-fuzzy-step "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *") @@ -1767,15 +1766,16 @@ matter is removed. Additional things can be deleted by setting "Simplify a subject string fuzzily. See `gnus-simplify-buffer-fuzzy' for details." (save-excursion - (gnus-set-work-buffer) - (let ((case-fold-search t)) - ;; Remove uninteresting prefixes. - (when (and gnus-simplify-ignored-prefixes - (string-match gnus-simplify-ignored-prefixes subject)) - (setq subject (substring subject (match-end 0)))) - (insert subject) - (inline (gnus-simplify-buffer-fuzzy)) - (buffer-string)))) + (let ((regexp gnus-simplify-subject-fuzzy-regexp)) + (gnus-set-work-buffer) + (let ((case-fold-search t)) + ;; Remove uninteresting prefixes. + (when (and gnus-simplify-ignored-prefixes + (string-match gnus-simplify-ignored-prefixes subject)) + (setq subject (substring subject (match-end 0)))) + (insert subject) + (inline (gnus-simplify-buffer-fuzzy regexp)) + (buffer-string))))) (defsubst gnus-simplify-subject-fully (subject) "Simplify a subject string according to `gnus-summary-gather-subject-limit'." @@ -6068,14 +6068,23 @@ If SELECT-ARTICLES, only select those articles from GROUP." 'request-set-mark gnus-newsgroup-name) (not (gnus-article-unpropagatable-p (cdr type)))) (let* ((old (cdr (assq (cdr type) (gnus-info-marks info)))) - (del (gnus-remove-from-range (gnus-copy-sequence old) list)) - (add (gnus-remove-from-range - (gnus-copy-sequence list) old))) + ;; Don't do anything about marks for articles we + ;; didn't actually get any headers for. + (existing (gnus-compress-sequence gnus-newsgroup-articles)) + (del + (gnus-sorted-range-intersection + existing + (gnus-remove-from-range (gnus-copy-sequence old) list))) + (add + (gnus-sorted-range-intersection + existing + (gnus-remove-from-range + (gnus-copy-sequence list) old)))) (when add (push (list add 'add (list (cdr type))) delta-marks)) (when del - ;; Don't delete marks from outside the active range. This - ;; shouldn't happen, but is a sanity check. + ;; Don't delete marks from outside the active range. + ;; This shouldn't happen, but is a sanity check. (setq del (gnus-sorted-range-intersection (gnus-active gnus-newsgroup-name) del)) (push (list del 'del (list (cdr type))) delta-marks)))) @@ -12142,10 +12151,7 @@ If REVERSE, save parts that do not match TYPE." mm-file-name-rewrite-functions (file-name-nondirectory (or - (mail-content-type-get - (mm-handle-disposition handle) 'filename) - (mail-content-type-get - (mm-handle-type handle) 'name) + (mm-handle-filename handle) (format "%s.%d.%d" gnus-newsgroup-name (cdr gnus-article-current) gnus-summary-save-parts-counter)))) diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el index 57d085a0380..d4ecd89db92 100644 --- a/lisp/gnus/gnus.el +++ b/lisp/gnus/gnus.el @@ -1043,12 +1043,15 @@ be set in `.emacs' instead." ((boundp 'image-load-path) (symbol-value 'image-load-path)) (t load-path))) - (image (find-image - `((:type xpm :file "gnus.xpm" + (image (gnus-splash-svg-color-symbols (find-image + `((:type svg :file "gnus.svg" + :color-symbols + (("#bf9900" . ,(car gnus-logo-colors)) + ("#ffcc00" . ,(cadr gnus-logo-colors)))) + (:type xpm :file "gnus.xpm" :color-symbols (("thing" . ,(car gnus-logo-colors)) ("shadow" . ,(cadr gnus-logo-colors)))) - (:type svg :file "gnus.svg") (:type png :file "gnus.png") (:type pbm :file "gnus.pbm" ;; Account for the pbm's background. @@ -1057,7 +1060,7 @@ be set in `.emacs' instead." (:type xbm :file "gnus.xbm" ;; Account for the xbm's background. :background ,(face-foreground 'gnus-splash) - :foreground ,(face-background 'default)))))) + :foreground ,(face-background 'default))))))) (when image (let ((size (image-size image))) (insert-char ?\n (max 0 (round (- (window-height) @@ -1103,6 +1106,20 @@ be set in `.emacs' instead." (setq mode-line-buffer-identification (concat " " gnus-version)) (set-buffer-modified-p t))) +(defun gnus-splash-svg-color-symbols (list) + "Do color-symbol search-and-replace in svg file" + (let ((type (plist-get (cdr list) :type)) + (file (plist-get (cdr list) :file)) + (color-symbols (plist-get (cdr list) :color-symbols))) + (if (string= type "svg") + (let ((data (with-temp-buffer (insert-file file) (buffer-string)))) + (mapc (lambda (rule) + (setq data (replace-regexp-in-string + (concat "fill:" (car rule)) + (concat "fill:" (cdr rule)) data))) color-symbols) + (cons (car list) (list :type type :data data))) + list))) + (eval-when (load) (let ((command (format "%s" this-command))) (when (string-match "gnus" command) diff --git a/lisp/gnus/gssapi.el b/lisp/gnus/gssapi.el index 3765fb84ee8..e96c23b14ac 100644 --- a/lisp/gnus/gssapi.el +++ b/lisp/gnus/gssapi.el @@ -33,14 +33,14 @@ "--authentication-id %l") "imtest -m gssapi -u %l -p %p %s") "List of strings containing commands for GSSAPI (krb5) authentication. -%s is replaced with server hostname, %p with port to connect to, and -%l with the value of `imap-default-user'. The program should accept -IMAP commands on stdin and return responses to stdout. Each entry in -the list is tried until a successful connection is made." +%s is replaced with server hostname, %p with port to connect to, +and %l with the user name. The program should accept commands on +stdin and return responses to stdout. Each entry in the list is +tried until a successful connection is made." :group 'network :type '(repeat string)) -(defun open-gssapi-stream (name buffer server port) +(defun open-gssapi-stream (name buffer server port user) (let ((cmds gssapi-program) cmd done) (with-current-buffer buffer @@ -57,7 +57,7 @@ the list is tried until a successful connection is made." (format-spec-make ?s server ?p (number-to-string port) - ?l imap-default-user)))) + ?l user)))) response) (when process (while (and (memq (process-status process) '(open run)) @@ -92,7 +92,7 @@ the list is tried until a successful connection is made." (accept-process-output process 1) (sit-for 1)) (erase-buffer) - (message "GSSAPI IMAP connection: %s" (or response "failed")) + (message "GSSAPI connection: %s" (or response "failed")) (if (and response (let ((case-fold-search nil)) (not (string-match "failed" response)))) (setq done process) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index bb9215aca7c..6d9fd712c33 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -3712,22 +3712,9 @@ To use this automatically, you may add this function to (while (re-search-forward citexp nil t) (replace-match (if remove "" "\n")))))) -(defun message-yank-original (&optional arg) - "Insert the message being replied to, if any. -Puts point before the text and mark after. -Normally indents each nonblank line ARG spaces (default 3). However, -if `message-yank-prefix' is non-nil, insert that prefix on each line. - -This function uses `message-cite-function' to do the actual citing. - -Just \\[universal-argument] as argument means don't indent, insert no -prefix, and don't delete any headers." - (interactive "P") +(defun message--yank-original-internal (arg) (let ((modified (buffer-modified-p)) body-text) - ;; eval the let forms contained in message-cite-style - (eval - `(let ,message-cite-style (when (and message-reply-buffer message-cite-function) (when (equal message-cite-reply-position 'above) @@ -3767,7 +3754,23 @@ prefix, and don't delete any headers." ;; Add a `message-setup-very-last-hook' here? ;; Add `gnus-article-highlight-citation' here? (unless modified - (setq message-checksum (message-checksum)))))))) + (setq message-checksum (message-checksum)))))) + +(defun message-yank-original (&optional arg) + "Insert the message being replied to, if any. +Puts point before the text and mark after. +Normally indents each nonblank line ARG spaces (default 3). However, +if `message-yank-prefix' is non-nil, insert that prefix on each line. + +This function uses `message-cite-function' to do the actual citing. + +Just \\[universal-argument] as argument means don't indent, insert no +prefix, and don't delete any headers." + (interactive "P") + ;; eval the let forms contained in message-cite-style + (eval + `(let ,message-cite-style + (message--yank-original-internal ',arg)))) (defun message-yank-buffer (buffer) "Insert BUFFER into the current buffer and quote it." diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el index 3909e12186f..f543920446b 100644 --- a/lisp/gnus/mm-decode.el +++ b/lisp/gnus/mm-decode.el @@ -1744,6 +1744,13 @@ If RECURSIVE, search recursively." (delete-region ,(point-min-marker) ,(point-max-marker)))))))) +(defun mm-handle-filename (handle) + "Return filename of HANDLE if any." + (or (mail-content-type-get (mm-handle-type handle) + 'name) + (mail-content-type-get (mm-handle-disposition handle) + 'filename))) + (provide 'mm-decode) ;;; mm-decode.el ends here diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el index d63d20239dc..abd78b8de02 100644 --- a/lisp/gnus/mm-view.el +++ b/lisp/gnus/mm-view.el @@ -455,7 +455,7 @@ (narrow-to-region (point) (point)) (mm-insert-part handle) (goto-char (point-max))) - (insert (mm-decode-string (mm-get-part handle) charset))) + (mm-display-inline-fontify handle)) (when (and mm-fill-flowed (equal type "plain") (equal (cdr (assoc 'format (mm-handle-type handle))) @@ -565,15 +565,16 @@ (face-property 'default prop) (current-buffer)))) (delete-region ,(point-min-marker) ,(point-max-marker))))))))) -(defun mm-display-inline-fontify (handle mode) +(defun mm-display-inline-fontify (handle &optional mode) + "Insert HANDLE inline fontifying with MODE. +If MODE is not set, try to find mode automatically." (let ((charset (mail-content-type-get (mm-handle-type handle) 'charset)) text coding-system) (unless (eq charset 'gnus-decoded) (mm-with-unibyte-buffer (mm-insert-part handle) (mm-decompress-buffer - (or (mail-content-type-get (mm-handle-disposition handle) 'name) - (mail-content-type-get (mm-handle-disposition handle) 'filename)) + (mm-handle-filename handle) t t) (unless charset (setq coding-system (mm-find-buffer-file-coding-system))) @@ -601,7 +602,11 @@ (font-lock-support-mode nil) ;; I find font-lock a bit too verbose. (font-lock-verbose nil)) - (funcall mode) + (setq buffer-file-name (mm-handle-filename handle)) + (set (make-local-variable 'enable-local-variables) nil) + (if mode + (funcall mode) + (set-auto-mode)) ;; The mode function might have already turned on font-lock. (unless (symbol-value 'font-lock-mode) (font-lock-fontify-buffer))) @@ -614,6 +619,9 @@ nil) nil nil nil nil nil 'text-prop)) (setq text (buffer-string)) + ;; Set buffer unmodified to avoid confirmation when killing the + ;; buffer. + (set-buffer-modified-p nil) (kill-buffer (current-buffer))) (mm-insert-inline handle text))) diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index bcbe7b678d5..fa09c7ff165 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -61,10 +61,12 @@ If nnimap-stream is `ssl', this will default to `imaps'. If not, it will default to `imap'.") (defvoo nnimap-stream 'undecided - "How nnimap will talk to the IMAP server. -Values are `ssl', `network', `network-only, `starttls' or -`shell'. The default is to try `ssl' first, and then -`network'.") + "How nnimap talks to the IMAP server. +The value should be either `undecided', `ssl' or `tls', +`network', `starttls', `plain', or `shell'. + +If the value is `undecided', nnimap tries `ssl' first, then falls +back on `network'.") (defvoo nnimap-shell-program (if (boundp 'imap-shell-program) (if (listp imap-shell-program) @@ -339,9 +341,7 @@ textual parts.") (port nil) (ports (cond - ((or (eq nnimap-stream 'network) - (eq nnimap-stream 'network-only) - (eq nnimap-stream 'starttls)) + ((memq nnimap-stream '(network plain starttls)) (nnheader-message 7 "Opening connection to %s..." nnimap-address) '("imap" "143")) @@ -355,21 +355,28 @@ textual parts.") '("imaps" "imap" "993" "143")) (t (error "Unknown stream type: %s" nnimap-stream)))) - (proto-stream-always-use-starttls t) login-result credentials) (when nnimap-server-port (push nnimap-server-port ports)) - (destructuring-bind (stream greeting capabilities stream-type) - (open-protocol-stream - "*nnimap*" (current-buffer) nnimap-address (car ports) - :type nnimap-stream - :shell-command nnimap-shell-program - :capability-command "1 CAPABILITY\r\n" - :success " OK " - :starttls-function - (lambda (capabilities) - (when (gnus-string-match-p "STARTTLS" capabilities) - "1 STARTTLS\r\n"))) + (let* ((stream-list + (open-protocol-stream + "*nnimap*" (current-buffer) nnimap-address (car ports) + :type nnimap-stream + :return-list t + :shell-command nnimap-shell-program + :capability-command "1 CAPABILITY\r\n" + :success " OK " + :starttls-function + (lambda (capabilities) + (when (gnus-string-match-p "STARTTLS" capabilities) + "1 STARTTLS\r\n")))) + (stream (car stream-list)) + (props (cdr stream-list)) + (greeting (plist-get props :greeting)) + (capabilities (plist-get props :capabilities)) + (stream-type (plist-get props :type))) + (when (and stream (not (memq (process-status stream) '(open run)))) + (setq stream nil)) (setf (nnimap-process nnimap-object) stream) (setf (nnimap-stream-type nnimap-object) stream-type) (if (not stream) @@ -403,11 +410,18 @@ textual parts.") (setq login-result (nnimap-login (car credentials) (cadr credentials)))) (if (car login-result) - ;; save the credentials if a save function exists + (progn + ;; Save the credentials if a save function exists ;; (such a function will only be passed if a new - ;; token was created) - (when (functionp (nth 2 credentials)) - (funcall (nth 2 credentials))) + ;; token was created). + (when (functionp (nth 2 credentials)) + (funcall (nth 2 credentials))) + ;; See if CAPABILITY is set as part of login + ;; response. + (dolist (response (cddr login-result)) + (when (string= "CAPABILITY" (upcase (car response))) + (setf (nnimap-capabilities nnimap-object) + (mapcar #'upcase (cdr response)))))) ;; If the login failed, then forget the credentials ;; that are now possibly cached. (dolist (host (list (nnoo-current-server 'nnimap) diff --git a/lisp/gnus/nntp.el b/lisp/gnus/nntp.el index 66a6365cb3b..fa765e17463 100644 --- a/lisp/gnus/nntp.el +++ b/lisp/gnus/nntp.el @@ -76,27 +76,27 @@ to innd, you could say something like: You probably don't want to do that, though.") (defvoo nntp-open-connection-function 'nntp-open-network-stream - "*Function used for connecting to a remote system. -It will be called with the buffer to output in as argument. - -Currently, five such functions are provided (please refer to their -respective doc string for more information), three of them establishing -direct connections to the nntp server, and two of them using an indirect -host. - -Direct connections: -- `nntp-open-network-stream' (the default), -- `network-only' (the same as the above, but don't do automatic - STARTTLS upgrades). -- `nntp-open-ssl-stream', -- `nntp-open-tls-stream', -- `nntp-open-netcat-stream'. -- `nntp-open-telnet-stream'. - -Indirect connections: -- `nntp-open-via-rlogin-and-netcat', -- `nntp-open-via-rlogin-and-telnet', -- `nntp-open-via-telnet-and-telnet'.") + "Method for connecting to a remote system. +It should be a function, which is called with the output buffer +as its single argument, or one of the following special values: + +- `nntp-open-network-stream' specifies a network connection, + upgrading to a TLS connection via STARTTLS if possible. +- `nntp-open-plain-stream' specifies an unencrypted network + connection (no STARTTLS upgrade is attempted). +- `nntp-open-ssl-stream' or `nntp-open-tls-stream' specify a TLS + network connection. + +Apart from the above special values, valid functions are as +follows; please refer to their respective doc string for more +information. +For direct connections: +- `nntp-open-netcat-stream' +- `nntp-open-telnet-stream' +For indirect connections: +- `nntp-open-via-rlogin-and-netcat' +- `nntp-open-via-rlogin-and-telnet' +- `nntp-open-via-telnet-and-telnet'") (defvoo nntp-never-echoes-commands nil "*Non-nil means the nntp server never echoes commands. @@ -1340,25 +1340,25 @@ password contained in '~/.nntp-authinfo'." (let ((coding-system-for-read nntp-coding-system-for-read) (coding-system-for-write nntp-coding-system-for-write) (map '((nntp-open-network-stream network) - (network-only network-only) + (network-only plain) ; compat + (nntp-open-plain-stream plain) (nntp-open-ssl-stream tls) (nntp-open-tls-stream tls)))) (if (assoc nntp-open-connection-function map) - (car (open-protocol-stream - "nntpd" pbuffer nntp-address nntp-port-number - :type (cadr - (assoc nntp-open-connection-function map)) - :end-of-command "^\\([2345]\\|[.]\\).*\n" - :capability-command "CAPABILITIES\r\n" - :success "^3" - :starttls-function - (lambda (capabilities) - (if (not (string-match "STARTTLS" capabilities)) - nil - "STARTTLS\r\n")))) + (open-protocol-stream + "nntpd" pbuffer nntp-address nntp-port-number + :type (cadr (assoc nntp-open-connection-function map)) + :end-of-command "^\\([2345]\\|[.]\\).*\n" + :capability-command "CAPABILITIES\r\n" + :success "^3" + :starttls-function + (lambda (capabilities) + (if (not (string-match "STARTTLS" capabilities)) + nil + "STARTTLS\r\n"))) (funcall nntp-open-connection-function pbuffer))) (error - (nnheader-report 'nntp "%s" err)) + (nnheader-report 'nntp ">>> %s" err)) (quit (message "Quit opening connection to %s" nntp-address) (nntp-kill-buffer pbuffer) @@ -1366,6 +1366,9 @@ password contained in '~/.nntp-authinfo'." nil)))) (when timer (nnheader-cancel-timer timer)) + (when (and process + (not (memq (process-status process) '(open run)))) + (setq process nil)) (unless process (nntp-kill-buffer pbuffer)) (when (and (buffer-name pbuffer) diff --git a/lisp/gnus/proto-stream.el b/lisp/gnus/proto-stream.el index fdf2abfea05..45cc974e7a9 100644 --- a/lisp/gnus/proto-stream.el +++ b/lisp/gnus/proto-stream.el @@ -48,171 +48,162 @@ ;;; Code: -(eval-when-compile - (require 'cl)) (require 'tls) (require 'starttls) -(require 'format-spec) - -(defcustom proto-stream-always-use-starttls (fboundp 'open-gnutls-stream) - "If non-nil, always try to upgrade network connections with STARTTLS." - :version "24.1" - :type 'boolean - :group 'comm) (declare-function gnutls-negotiate "gnutls" (proc type &optional priority-string trustfiles keyfiles)) ;;;###autoload (defun open-protocol-stream (name buffer host service &rest parameters) - "Open a network stream to HOST, upgrading to STARTTLS if possible. -The first four parameters have the same meaning as in -`open-network-stream'. The function returns a list where the -first element is the stream, the second element is the greeting -the server replied with after connecting, and the third element -is a string representing the capabilities of the server (if any). - -The PARAMETERS is a keyword list that can have the following -values: - -:type -- either `network', `network-only, `tls', `shell' or -`starttls'. If omitted, the default is `network'. `network' -will be opportunistically upgraded to STARTTLS if both the server -and Emacs supports it. If you don't want STARTTLS upgrades, use -`network-only'. - -:end-of-command -- a regexp saying what the end of a command is. -This defaults to \"\\n\". - -:success -- a regexp saying whether the STARTTLS command was -successful or not. For instance, for NNTP this is \"^3\". - -:capability-command -- a string representing the command used to -query server for capabilities. For instance, for IMAP this is -\"1 CAPABILITY\\r\\n\". - -:starttls-function -- a function that takes one parameter, which -is the response to the capaibility command. It should return nil -if it turns out that the server doesn't support STARTTLS, or the -command to switch on STARTTLS otherwise. - -The return value from this function is a four-element list, where -the first element is the stream (if connection was successful); -the second element is the \"greeting\", i. e., the string the -server sent over on initial contact; the third element is the -capability string; and the fourth element is either `network' or -`tls', depending on whether the connection ended up being -encrypted or not." - (let ((type (or (cadr (memq :type parameters)) 'network))) - (cond - ((eq type 'starttls) - (setq type 'network)) - ((eq type 'ssl) - (setq type 'tls))) - (let ((open-result - (funcall (intern (format "proto-stream-open-%s" type) obarray) - name buffer host service parameters))) - (if (null open-result) - (list nil nil nil type) - (let ((stream (car open-result))) - (list (and stream - (memq (process-status stream) - '(open run)) - stream) - (nth 1 open-result) - (nth 2 open-result) - (nth 3 open-result))))))) - -(defun proto-stream-open-network-only (name buffer host service parameters) + "Open a network stream to HOST, possibly with encryption. +Normally, return a network process object; with a non-nil +:return-list parameter, return a list instead (see below). + +The first four parameters, NAME, BUFFER, HOST, and SERVICE, have +the same meanings as in `open-network-stream'. The remaining +PARAMETERS should be a sequence of keywords and values: + +:type specifies the connection type, one of the following: + nil or `network' + -- Begin with an ordinary network connection, and if + the parameters :success and :capability-command + are also supplied, try to upgrade to an encrypted + connection via STARTTLS. Even if that + fails (e.g. if HOST does not support TLS), retain + an unencrypted connection. + `plain' -- An ordinary, unencrypted network connection. + `starttls' -- Begin with an ordinary connection, and try + upgrading via STARTTLS. If that fails for any + reason, drop the connection; in that case the + returned object is a killed process. + `tls' -- A TLS connection. + `ssl' -- Equivalent to `tls'. + `shell' -- A shell connection. + +:return-list specifies this function's return value. + If omitted or nil, return a process object. A non-nil means to + return (PROC . PROPS), where PROC is a process object and PROPS + is a plist of connection properties, with these keywords: + :greeting -- the greeting returned by HOST (a string), or nil. + :capabilities -- a string representing HOST's capabilities, + or nil if none could be found. + :type -- the resulting connection type; `plain' (unencrypted) + or `tls' (TLS-encrypted). + +:end-of-command specifies a regexp matching the end of a command. + If non-nil, it defaults to \"\\n\". + +:success specifies a regexp matching a message indicating a + successful STARTTLS negotiation. For instance, the default + should be \"^3\" for an NNTP connection. + +:capability-command specifies a command used to query the HOST + for its capabilities. For instance, for IMAP this should be + \"1 CAPABILITY\\r\\n\". + +:starttls-function specifies a function for handling STARTTLS. + This function should take one parameter, the response to the + capability command, and should return the command to switch on + STARTTLS if the server supports STARTTLS, and nil otherwise." + (let ((type (plist-get parameters :type)) + (return-list (plist-get parameters :return-list))) + (if (and (not return-list) + (or (eq type 'plain) + (and (memq type '(nil network)) + (not (and (plist-get parameters :success) + (plist-get parameters :capability-command)))))) + ;; The simplest case is equivalent to `open-network-stream'. + (open-network-stream name buffer host service) + ;; For everything else, refer to proto-stream-open-*. + (unless (plist-get parameters :end-of-command) + (setq parameters (append '(:end-of-command "\r\n") parameters))) + (let* ((connection-function + (cond + ((eq type 'plain) 'proto-stream-open-plain) + ((memq type '(nil network starttls)) + 'proto-stream-open-starttls) + ((memq type '(tls ssl)) 'proto-stream-open-tls) + ((eq type 'shell) 'proto-stream-open-shell) + (t (error "Invalid connection type %s" type)))) + (result (funcall connection-function + name buffer host service parameters))) + (if return-list + (list (car result) + :greeting (nth 1 result) + :capabilities (nth 2 result) + :type (nth 3 result)) + (car result)))))) + +(defun proto-stream-open-plain (name buffer host service parameters) (let ((start (with-current-buffer buffer (point))) (stream (open-network-stream name buffer host service))) (list stream - (proto-stream-get-response - stream start (proto-stream-eoc parameters)) + (proto-stream-get-response stream start + (plist-get parameters :end-of-command)) nil - 'network))) + 'plain))) -(defun proto-stream-open-network (name buffer host service parameters) +(defun proto-stream-open-starttls (name buffer host service parameters) (let* ((start (with-current-buffer buffer (point))) + (require-tls (eq (plist-get parameters :type) 'starttls)) + (starttls-function (plist-get parameters :starttls-function)) + (success-string (plist-get parameters :success)) + (capability-command (plist-get parameters :capability-command)) + (eoc (plist-get parameters :end-of-command)) + ;; Return (STREAM GREETING CAPABILITIES RESULTING-TYPE) (stream (open-network-stream name buffer host service)) - (capability-command (cadr (memq :capability-command parameters))) - (eoc (proto-stream-eoc parameters)) - (type (cadr (memq :type parameters))) (greeting (proto-stream-get-response stream start eoc)) - success) - (if (not capability-command) - (list stream greeting nil 'network) - (let* ((capabilities - (proto-stream-command stream capability-command eoc)) - (starttls-command - (funcall (cadr (memq :starttls-function parameters)) - capabilities))) - (cond - ;; If this server doesn't support STARTTLS, but we have - ;; requested it explicitly, then close the connection and - ;; return nil. - ((or (not starttls-command) - (and (not (eq type 'starttls)) - (not proto-stream-always-use-starttls))) - (if (eq type 'starttls) - (progn - (delete-process stream) - nil) - ;; Otherwise, just return this plain network connection. - (list stream greeting capabilities 'network))) - ;; We have some kind of STARTTLS support, so we try to - ;; upgrade the connection opportunistically. - ((or (fboundp 'open-gnutls-stream) - (executable-find "gnutls-cli")) - (unless (fboundp 'open-gnutls-stream) - (delete-process stream) - (setq start (with-current-buffer buffer (point-max))) - (let* ((starttls-use-gnutls t) - (starttls-extra-arguments - (if (not (eq type 'starttls)) - ;; When doing opportunistic TLS upgrades we - ;; don't really care about the identity of the - ;; peer. - (cons "--insecure" starttls-extra-arguments) - starttls-extra-arguments))) - (setq stream (starttls-open-stream name buffer host service))) - (proto-stream-get-response stream start eoc)) - (if (not - (string-match - (cadr (memq :success parameters)) - (proto-stream-command stream starttls-command eoc))) - ;; We got an error back from the STARTTLS command. - (progn - (if (eq type 'starttls) - (progn - (delete-process stream) - nil) - (list stream greeting capabilities 'network))) - ;; The server said it was OK to start doing STARTTLS negotiations. - (if (fboundp 'open-gnutls-stream) - (gnutls-negotiate stream nil) - (unless (starttls-negotiate stream) - (delete-process stream) - (setq stream nil))) - (when (or (null stream) - (not (memq (process-status stream) - '(open run)))) - ;; It didn't successfully negotiate STARTTLS, so we reopen - ;; the connection. - (setq stream (open-network-stream name buffer host service)) - (proto-stream-get-response stream start eoc)) - ;; Re-get the capabilities, since they may have changed - ;; after switching to TLS. - (list stream greeting - (proto-stream-command stream capability-command eoc) 'tls))) - ;; We don't have STARTTLS support available, but the caller - ;; requested a STARTTLS connection, so we give up. - ((eq (cadr (memq :type parameters)) 'starttls) - (delete-process stream) - nil) - ;; Fall back on using a plain network stream. - (t - (list stream greeting capabilities 'network))))))) + (capabilities (when capability-command + (proto-stream-command stream + capability-command eoc))) + (resulting-type 'plain) + starttls-command) + + ;; If we have STARTTLS support, try to upgrade the connection. + (when (and (or (fboundp 'open-gnutls-stream) + (executable-find "gnutls-cli")) + capabilities success-string starttls-function + (setq starttls-command + (funcall starttls-function capabilities))) + ;; If using external STARTTLS, drop this connection and start + ;; anew with `starttls-open-stream'. + (unless (fboundp 'open-gnutls-stream) + (delete-process stream) + (setq start (with-current-buffer buffer (point-max))) + (let* ((starttls-use-gnutls t) + (starttls-extra-arguments + (if require-tls + starttls-extra-arguments + ;; For opportunistic TLS upgrades, we don't really + ;; care about the identity of the peer. + (cons "--insecure" starttls-extra-arguments)))) + (setq stream (starttls-open-stream name buffer host service))) + (proto-stream-get-response stream start eoc)) + (when (string-match success-string + (proto-stream-command stream starttls-command eoc)) + ;; The server said it was OK to begin STARTTLS negotiations. + (if (fboundp 'open-gnutls-stream) + (gnutls-negotiate stream nil) + (unless (starttls-negotiate stream) + (delete-process stream))) + (if (memq (process-status stream) '(open run)) + (setq resulting-type 'tls) + ;; We didn't successfully negotiate STARTTLS; if TLS + ;; isn't demanded, reopen an unencrypted connection. + (unless require-tls + (setq stream (open-network-stream name buffer host service)) + (proto-stream-get-response stream start eoc))) + ;; Re-get the capabilities, which may have now changed. + (setq capabilities + (proto-stream-command stream capability-command eoc)))) + + ;; If TLS is mandatory, close the connection if it's unencrypted. + (and require-tls + (eq resulting-type 'plain) + (delete-process stream)) + ;; Return value: + (list stream greeting capabilities resulting-type))) (defun proto-stream-command (stream command eoc) (let ((start (with-current-buffer (process-buffer stream) (point-max)))) @@ -241,47 +232,43 @@ encrypted or not." (funcall (if (fboundp 'open-gnutls-stream) 'open-gnutls-stream 'open-tls-stream) - name buffer host service))) + name buffer host service)) + (eoc (plist-get parameters :end-of-command))) (if (null stream) - nil + (list nil nil nil 'plain) ;; If we're using tls.el, we have to delete the output from ;; openssl/gnutls-cli. (unless (fboundp 'open-gnutls-stream) - (proto-stream-get-response - stream start (proto-stream-eoc parameters)) + (proto-stream-get-response stream start eoc) (goto-char (point-min)) - (when (re-search-forward (proto-stream-eoc parameters) nil t) + (when (re-search-forward eoc nil t) (goto-char (match-beginning 0)) (delete-region (point-min) (line-beginning-position)))) (proto-stream-capability-open start stream parameters 'tls))))) (defun proto-stream-open-shell (name buffer host service parameters) + (require 'format-spec) (proto-stream-capability-open (with-current-buffer buffer (point)) (let ((process-connection-type nil)) (start-process name buffer shell-file-name shell-command-switch (format-spec - (cadr (memq :shell-command parameters)) + (plist-get parameters :shell-command) (format-spec-make ?s host ?p service)))) - parameters 'network)) + parameters 'plain)) (defun proto-stream-capability-open (start stream parameters stream-type) - (let ((capability-command (cadr (memq :capability-command parameters))) - (greeting (proto-stream-get-response - stream start (proto-stream-eoc parameters)))) + (let* ((capability-command (plist-get parameters :capability-command)) + (eoc (plist-get parameters :end-of-command)) + (greeting (proto-stream-get-response stream start eoc))) (list stream greeting (and capability-command - (proto-stream-command - stream capability-command (proto-stream-eoc parameters))) + (proto-stream-command stream capability-command eoc)) stream-type))) -(defun proto-stream-eoc (parameters) - (or (cadr (memq :end-of-command parameters)) - "\r\n")) - (provide 'proto-stream) ;;; proto-stream.el ends here diff --git a/lisp/help-mode.el b/lisp/help-mode.el index 51d18235e1b..005358e3c7d 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el @@ -330,7 +330,7 @@ Commands: (save-excursion (goto-char (point-min)) (let ((inhibit-read-only t)) - (when (re-search-forward "^This \\w+ is advised.$" nil t) + (when (re-search-forward "^This [^[:space:]]+ is advised.$" nil t) (put-text-property (match-beginning 0) (match-end 0) 'face 'font-lock-warning-face)))) diff --git a/lisp/ido.el b/lisp/ido.el index 2a5c7cf2f0e..0ce83d9b88c 100644 --- a/lisp/ido.el +++ b/lisp/ido.el @@ -1964,31 +1964,24 @@ If INITIAL is non-nil, it specifies the initial input string." (ido-set-matches) (if (and ido-matches (eq ido-try-merged-list 'auto)) (setq ido-try-merged-list t)) - (let - ((minibuffer-local-completion-map - (if (memq ido-cur-item '(file dir)) - minibuffer-local-completion-map - ido-completion-map)) - (minibuffer-local-filename-completion-map - (if (memq ido-cur-item '(file dir)) - ido-completion-map - minibuffer-local-filename-completion-map)) - (max-mini-window-height (or ido-max-window-height - (and (boundp 'max-mini-window-height) max-mini-window-height))) + (let ((max-mini-window-height (or ido-max-window-height + (and (boundp 'max-mini-window-height) + max-mini-window-height))) (ido-completing-read t) (ido-require-match require-match) (ido-use-mycompletion-depth (1+ (minibuffer-depth))) - (show-paren-mode nil)) + (show-paren-mode nil) + ;; Postpone history adding till later + (history-add-new-input nil)) ;; prompt the user for the file name (setq ido-exit nil) (setq ido-final-text (catch 'ido - (completing-read-default - (ido-make-prompt item prompt) - '(("dummy" . 1)) nil nil ; table predicate require-match - (prog1 ido-text-init (setq ido-text-init nil)) ;initial-contents - history)))) - (ido-trace "completing-read" ido-final-text) + (read-from-minibuffer (ido-make-prompt item prompt) + (prog1 ido-text-init + (setq ido-text-init nil)) + ido-completion-map nil history)))) + (ido-trace "read-from-minibuffer" ido-final-text) (if (get-buffer ido-completion-buffer) (kill-buffer ido-completion-buffer)) @@ -2158,6 +2151,7 @@ If INITIAL is non-nil, it specifies the initial input string." (t (setq done t)))))) + (add-to-history (or history 'minibuffer-history) ido-selected) ido-selected)) (defun ido-edit-input () @@ -4491,17 +4485,13 @@ For details of keybindings, see `ido-find-file'." ;; Insert the match-status information: (ido-set-common-completion) - (let ((inf (ido-completions - contents - minibuffer-completion-table - minibuffer-completion-predicate - (not minibuffer-completion-confirm)))) + (let ((inf (ido-completions contents))) (setq ido-show-confirm-message nil) (ido-trace "inf" inf) (insert inf)) )))) -(defun ido-completions (name candidates predicate require-match) +(defun ido-completions (name) ;; Return the string that is displayed after the user's text. ;; Modified from `icomplete-completions'. diff --git a/lisp/image.el b/lisp/image.el index 627d4c69e44..3b90ac46bd1 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -60,7 +60,7 @@ IMAGE-TYPE must be a pair (PREDICATE . TYPE). PREDICATE is called with one argument, a string containing the image data. If PREDICATE returns a non-nil value, TYPE is the image's type.") -(defconst image-type-file-name-regexps +(defvar image-type-file-name-regexps '(("\\.png\\'" . png) ("\\.gif\\'" . gif) ("\\.jpe?g\\'" . jpeg) @@ -710,17 +710,19 @@ shall be displayed." ;;;###autoload (defun imagemagick-register-types () "Register the file types that ImageMagick is able to handle." - (let ((im-types (imagemagick-types))) - (dolist (im-inhibit imagemagick-types-inhibit) - (setq im-types (remove im-inhibit im-types))) - (dolist (im-type im-types) - (let ((extension (downcase (symbol-name im-type)))) - (push - (cons (concat "\\." extension "\\'") 'image-mode) - auto-mode-alist) - (push - (cons (concat "\\." extension "\\'") 'imagemagick) - image-type-file-name-regexps))))) + (if (fboundp 'imagemagick-types) + (let ((im-types (imagemagick-types))) + (dolist (im-inhibit imagemagick-types-inhibit) + (setq im-types (remove im-inhibit im-types))) + (dolist (im-type im-types) + (let ((extension (downcase (symbol-name im-type)))) + (push + (cons (concat "\\." extension "\\'") 'image-mode) + auto-mode-alist) + (push + (cons (concat "\\." extension "\\'") 'imagemagick) + image-type-file-name-regexps)))) + (error "Emacs was not built with ImageMagick support"))) (provide 'image) diff --git a/lisp/midnight.el b/lisp/midnight.el index 9a6b162e986..762bc5445ba 100644 --- a/lisp/midnight.el +++ b/lisp/midnight.el @@ -39,8 +39,6 @@ (eval-when-compile (require 'cl)) -(require 'timer) - (defgroup midnight nil "Run something every day at midnight." :group 'calendar @@ -66,12 +64,6 @@ call `cancel-timer' or `timer-activate' on `midnight-timer' instead." ;;; time conversion -(defun midnight-time-float (num) - "Convert the float number of seconds since epoch to the list of 3 integers." - (let* ((div (ash 1 16)) (1st (floor num div))) - (list 1st (floor (- num (* (float div) 1st))) - (round (* 10000000 (mod num 1)))))) - (defun midnight-buffer-display-time (&optional buffer) "Return the time-stamp of BUFFER, or current buffer, as float." (with-current-buffer (or buffer (current-buffer)) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 4a2deb6b3bf..9d304ca8156 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -682,6 +682,8 @@ scroll the window of possible completions." (t t))))) (defun completion--flush-all-sorted-completions (&rest _ignore) + (remove-hook 'after-change-functions + 'completion--flush-all-sorted-completions t) (setq completion-cycling nil) (setq completion-all-sorted-completions nil)) @@ -1236,6 +1238,8 @@ Point needs to be somewhere between START and END." (assert (<= start (point)) (<= (point) end)) ;; FIXME: undisplay the *Completions* buffer once the completion is done. (with-wrapper-hook + ;; FIXME: Maybe we should use this hook to provide a "display + ;; completions" operation as well. completion-in-region-functions (start end collection predicate) (let ((minibuffer-completion-table collection) (minibuffer-completion-predicate predicate) @@ -1247,7 +1251,9 @@ Point needs to be somewhere between START and END." (defvar completion-at-point-functions '(tags-completion-at-point-function) "Special hook to find the completion table for the thing at point. -It is called without any argument and should return either nil, +Each function on this hook is called in turns without any argument and should +return either nil to mean that it is not applicable at point, +or t to mean that it already performed completion (discouraged), or a function of no argument to perform completion (discouraged), or a list of the form (START END COLLECTION &rest PROPS) where START and END delimit the entity to complete and should include point, @@ -1265,7 +1271,7 @@ The completion method is determined by `completion-at-point-functions'." 'completion-at-point-functions))) (cond ((functionp res) (funcall res)) - (res + ((consp res) (let* ((plist (nthcdr 3 res)) (start (nth 0 res)) (end (nth 1 res)) @@ -1273,7 +1279,8 @@ The completion method is determined by `completion-at-point-functions'." (or (plist-get plist :annotation-function) completion-annotate-function))) (completion-in-region start end (nth 2 res) - (plist-get plist :predicate))))))) + (plist-get plist :predicate)))) + (res)))) ;Maybe completion already happened and the function returned t. ;;; Key bindings. @@ -1480,8 +1487,9 @@ except that it passes the file name through `substitute-in-file-name'." 'completion--file-name-table) "Internal subroutine for `read-file-name'. Do not call this.") -(defvar read-file-name-function nil - "If this is non-nil, `read-file-name' does its work by calling this function.") +(defvar read-file-name-function 'read-file-name-default + "The function called by `read-file-name' to do its work. +It should accept the same arguments as `read-file-name'.") (defcustom read-file-name-completion-ignore-case (if (memq system-type '(ms-dos windows-nt darwin cygwin)) @@ -1519,7 +1527,7 @@ such as making the current buffer visit no file in the case of (declare-function x-file-dialog "xfns.c" (prompt dir &optional default-filename mustmatch only-dir-p)) -(defun read-file-name-defaults (&optional dir initial) +(defun read-file-name--defaults (&optional dir initial) (let ((default (cond ;; With non-nil `initial', use `dir' as the first default. @@ -1586,6 +1594,12 @@ treated as equivalent to nil. See also `read-file-name-completion-ignore-case' and `read-file-name-function'." + (funcall (or read-file-name-function #'read-file-name-default) + prompt dir default-filename mustmatch initial predicate)) + +(defun read-file-name-default (prompt &optional dir default-filename mustmatch initial predicate) + "Default method for reading file names. +See `read-file-name' for the meaning of the arguments." (unless dir (setq dir default-directory)) (unless (file-name-absolute-p dir) (setq dir (expand-file-name dir))) (unless default-filename @@ -1607,9 +1621,6 @@ and `read-file-name-function'." (minibuffer--double-dollars dir))) (initial (cons (minibuffer--double-dollars initial) 0))))) - (if read-file-name-function - (funcall read-file-name-function - prompt dir default-filename mustmatch initial predicate) (let ((completion-ignore-case read-file-name-completion-ignore-case) (minibuffer-completing-file-name t) (pred (or predicate 'file-exists-p)) @@ -1645,7 +1656,7 @@ and `read-file-name-function'." (lambda () (with-current-buffer (window-buffer (minibuffer-selected-window)) - (read-file-name-defaults dir initial))))) + (read-file-name--defaults dir initial))))) (completing-read prompt 'read-file-name-internal pred mustmatch insdef 'file-name-history default-filename))) @@ -1719,7 +1730,7 @@ and `read-file-name-function'." (if history-delete-duplicates (delete val1 file-name-history) file-name-history))))))) - val))))) + val)))) (defun internal-complete-buffer-except (&optional buffer) "Perform completion on all buffers excluding BUFFER. diff --git a/lisp/net/imap.el b/lisp/net/imap.el index 6d80b97fd23..f4af03f100f 100644 --- a/lisp/net/imap.el +++ b/lisp/net/imap.el @@ -211,7 +211,7 @@ until a successful connection is made." :type '(repeat string)) (defcustom imap-process-connection-type nil - "*Value for `process-connection-type' to use for Kerberos4, GSSAPI and SSL. + "*Value for `process-connection-type' to use for Kerberos4, GSSAPI, shell, and SSL. The `process-connection-type' variable controls the type of device used to communicate with subprocesses. Values are nil to use a pipe, or t or `pty' to use a pty. The value has no effect if the @@ -770,6 +770,7 @@ sure of changing the value of `foo'." (let* ((port (or port imap-default-port)) (coding-system-for-read imap-coding-system-for-read) (coding-system-for-write imap-coding-system-for-write) + (process-connection-type imap-process-connection-type) (process (start-process name buffer shell-file-name shell-command-switch (format-spec diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 71aa0dd22bc..eb4ad01ecd7 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -491,6 +491,7 @@ If ARG is non-nil, instead prompt for connection parameters." (defvar rcirc-server nil) ; server provided by server (defvar rcirc-server-name nil) ; server name given by 001 response (defvar rcirc-timeout-timer nil) +(defvar rcirc-user-authenticated nil) (defvar rcirc-user-disconnect nil) (defvar rcirc-connecting nil) (defvar rcirc-process nil) @@ -828,18 +829,21 @@ The list is updated automatically by `defun-rcirc-command'.") (defun rcirc-completion-at-point () "Function used for `completion-at-point-functions' in `rcirc-mode'." - (let* ((beg (save-excursion - (if (re-search-backward " " rcirc-prompt-end-marker t) - (1+ (point)) - rcirc-prompt-end-marker))) - (table (if (and (= beg rcirc-prompt-end-marker) - (eq (char-after beg) ?/)) - (delete-dups - (nconc - (sort (copy-sequence rcirc-client-commands) 'string-lessp) - (sort (copy-sequence rcirc-server-commands) 'string-lessp))) - (rcirc-channel-nicks (rcirc-buffer-process) rcirc-target)))) - (list beg (point) table))) + (and (rcirc-looking-at-input) + (let* ((beg (save-excursion + (if (re-search-backward " " rcirc-prompt-end-marker t) + (1+ (point)) + rcirc-prompt-end-marker))) + (table (if (and (= beg rcirc-prompt-end-marker) + (eq (char-after beg) ?/)) + (delete-dups + (nconc (sort (copy-sequence rcirc-client-commands) + 'string-lessp) + (sort (copy-sequence rcirc-server-commands) + 'string-lessp))) + (rcirc-channel-nicks (rcirc-buffer-process) + rcirc-target)))) + (list beg (point) table)))) (defvar rcirc-completions nil) (defvar rcirc-completion-start nil) @@ -848,6 +852,8 @@ The list is updated automatically by `defun-rcirc-command'.") "Cycle through completions from list of nicks in channel or IRC commands. IRC command completion is performed only if '/' is the first input char." (interactive) + (unless (rcirc-looking-at-input) + (error "Point not located after rcirc prompt")) (if (eq last-command this-command) (setq rcirc-completions (append (cdr rcirc-completions) (list (car rcirc-completions)))) @@ -855,9 +861,10 @@ IRC command completion is performed only if '/' is the first input char." (table (rcirc-completion-at-point))) (setq rcirc-completion-start (car table)) (setq rcirc-completions - (all-completions (buffer-substring rcirc-completion-start - (cadr table)) - (nth 2 table))))) + (and rcirc-completion-start + (all-completions (buffer-substring rcirc-completion-start + (cadr table)) + (nth 2 table)))))) (let ((completion (car rcirc-completions))) (when completion (delete-region rcirc-completion-start (point)) diff --git a/lisp/abbrevlist.el b/lisp/obsolete/abbrevlist.el index 79080780005..55940dfc1ce 100644 --- a/lisp/abbrevlist.el +++ b/lisp/obsolete/abbrevlist.el @@ -6,6 +6,7 @@ ;; Maintainer: FSF ;; Keywords: abbrev ;; Package: emacs +;; Obsolete-since: 24.1 ;; This file is part of GNU Emacs. diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index ab315f9eefd..6aece579d5d 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -648,7 +648,7 @@ detailed description of this mode. (set (make-local-variable 'gud-minor-mode) 'gdbmi) (setq comint-input-sender 'gdb-send) (when (ring-empty-p comint-input-ring) ; cf shell-mode - (let ((hfile (expand-file-name (or (getenv "GBDHISTFILE") + (let ((hfile (expand-file-name (or (getenv "GDBHISTFILE") (if (eq system-type 'ms-dos) "_gdb_history" ".gdb_history")))) diff --git a/lisp/simple.el b/lisp/simple.el index e4c742b56f4..a414fc77a39 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3346,16 +3346,16 @@ and KILLP is t if a prefix arg was specified." (delete-char 1))) (forward-char -1) (setq count (1- count)))))) - (delete-backward-char - (let ((skip (cond ((eq backward-delete-char-untabify-method 'hungry) " \t") + (let* ((skip (cond ((eq backward-delete-char-untabify-method 'hungry) " \t") ((eq backward-delete-char-untabify-method 'all) - " \t\n\r")))) - (if skip - (let ((wh (- (point) (save-excursion (skip-chars-backward skip) - (point))))) - (+ arg (if (zerop wh) 0 (1- wh)))) - arg)) - killp)) + " \t\n\r"))) + (n (if skip + (let ((wh (- (point) (save-excursion (skip-chars-backward skip) + (point))))) + (+ arg (if (zerop wh) 0 (1- wh)))) + arg))) + ;; Avoid warning about delete-backward-char + (with-no-warnings (delete-backward-char n killp)))) (defun zap-to-char (arg char) "Kill up to and including ARGth occurrence of CHAR. diff --git a/lisp/subr.el b/lisp/subr.el index 205828b4169..e6e0c62e0b4 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1122,6 +1122,8 @@ is converted into a string by expressing it in decimal." (make-obsolete-variable 'define-key-rebound-commands nil "23.2") (make-obsolete-variable 'redisplay-end-trigger-functions 'jit-lock-register "23.1") +(make-obsolete-variable 'deferred-action-list 'post-command-hook "24.1") +(make-obsolete-variable 'deferred-action-function 'post-command-hook "24.1") (make-obsolete 'window-redisplay-end-trigger nil "23.1") (make-obsolete 'set-window-redisplay-end-trigger nil "23.1") diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 020faa197cd..a56c3e4d501 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -207,6 +207,12 @@ a symbol as a valid THING." (cons opoint end)))) (error nil))))) +;; Defuns + +(put 'defun 'beginning-op 'beginning-of-defun) +(put 'defun 'end-op 'end-of-defun) +(put 'defun 'forward-op 'end-of-defun) + ;; Filenames and URLs www.com/foo%32bar (defvar thing-at-point-file-name-chars "-~/[:alnum:]_.${}#%,:" diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el index d9a06c8a401..9f6ad19fdb1 100644 --- a/lisp/vc/log-view.el +++ b/lisp/vc/log-view.el @@ -122,9 +122,6 @@ :group 'pcl-cvs :prefix "log-view-") -;; Needed because log-view-mode-map inherits from widget-keymap. (Bug#5311) -(require 'wid-edit) - (easy-mmode-defmap log-view-mode-map '( ;; FIXME: (copy-keymap special-mode-map) instead |