Commit 9f0b1513 authored by Paul Eggert's avatar Paul Eggert
Browse files

Merge from trunk.

parents e92b6c88 31fd4b32
......@@ -109,6 +109,26 @@ and pops down the *Completions* buffer accordingly.
** auto-mode-case-fold is now enabled by default.
** smtpmail changes
** smtpmail has been largely rewritten to upgrade to STARTTLS if
possible, and uses the auth-source framework for getting credentials.
The rewrite should be largely compatible with previous versions of
smtpmail, but there are two major incompatibilities:
** `smtpmail-auth-credentials' no longer exists. That variable could
be either ~/.authinfo (in which case you're fine -- you won't see any
difference), but if it were a direct list of user names and passwords,
you will be prompted for the user name and the password instead, and
they will then be saved to ~/.authinfo.
** Similarly, if you had `smtpmail-starttls-credentials' set, then
then you need to put
machine port 25 key "~/.my_smtp_tls.key" cert "~/.my_smtp_tls.cert"
in your ~/.authinfo file instead.
** Internationalization changes
2011-06-22 Lars Magne Ingebrigtsen <>
* mail/smtpmail.el (smtpmail-via-smtp): Make sure we don't send
QUIT twice.
(smtpmail-try-auth-methods): Require user name and password from
2011-06-22 Martin Rudalics <>
* window.el (display-buffer-default-specifiers)
(display-buffer-alist): Remove entries for pop-up-frame-alist.
Suggested by Katsumi Yamaoka <>.
(split-window): Normalize SIDE argument (Bug#8916).
* frame.el (pop-up-frame-alist, pop-up-frame-function)
(special-display-frame-alist, special-display-popup-frame):
Remove duplicate declarations. These are now in window.el.
2011-06-21 Lars Magne Ingebrigtsen <>
* mail/smtpmail.el (smtpmail-via-smtp): Set
:use-starttls-if-possible so that we always use STARTTLS if the
server supports it. SMTP servers that support STARTTLS commonly
require it.
* net/network-stream.el (network-stream-open-starttls): Support
upgrading to STARTTLS always, even if we don't have built-in support.
(open-network-stream): Add the :always-query-capabilies keyword.
* mail/smtpmail.el: Rewritten to do opportunistic STARTTLS
upgrades with `open-network-stream', and rely solely on
auth-source for all credentials. Big changes throughout the file,
but in particular:
(smtpmail-auth-credentials): Removed.
(smtpmail-starttls-credentials): Removed.
(smtpmail-via-smtp): Check for servers saying they want AUTH after
* net/network-stream.el (network-stream-open-starttls): Provide
support for client certificates both for external and built-in
(auth-source): Require.
(open-network-stream): Document the :client-certificate keyword.
(network-stream-certificate): Change cert-cert to cert and
cert-key to key.
2011-06-21 Michael Albinus <>
* net/tramp-cache.el (top): Don't load the persistency file when
"emacs -Q" has been called.
2011-06-21 Tim Harper <>
* term/ns-win.el (ns-initialize-window-system): set
application-specific `ApplePressAndHoldEnabled' system
resource to NO as it is not yet supported by the NS port.
2011-06-21 Juanma Barranquero <>
* misc.el (list-dynamic-libraries--refresh): Compute header here...
......@@ -95,96 +95,6 @@ appended when the minibuffer frame is created."
(sexp :tag "Value")))
:group 'frames)
(defcustom pop-up-frame-alist nil
"Alist of parameters for automatically generated new frames.
You can set this in your init file; for example,
(setq pop-up-frame-alist '((width . 80) (height . 20)))
If non-nil, the value you specify here is used by the default
`pop-up-frame-function' for the creation of new frames.
Since `pop-up-frame-function' is used by `display-buffer' for
making new frames, any value specified here by default affects
the automatic generation of new frames via `display-buffer' and
all functions based on it. The behavior of `make-frame' is not
affected by this variable."
:type '(repeat (cons :format "%v"
(symbol :tag "Parameter")
(sexp :tag "Value")))
:group 'frames)
(defcustom pop-up-frame-function
(lambda () (make-frame pop-up-frame-alist))
"Function used by `display-buffer' for creating a new frame.
This function is called with no arguments and should return a new
frame. The default value calls `make-frame' with the argument
:type 'function
:group 'frames)
(defcustom special-display-frame-alist
'((height . 14) (width . 80) (unsplittable . t))
"Alist of parameters for special frames.
Special frames are used for buffers whose names are listed in
`special-display-buffer-names' and for buffers whose names match
one of the regular expressions in `special-display-regexps'.
This variable can be set in your init file, like this:
(setq special-display-frame-alist '((width . 80) (height . 20)))
These supersede the values given in `default-frame-alist'."
:type '(repeat (cons :format "%v"
(symbol :tag "Parameter")
(sexp :tag "Value")))
:group 'frames)
(defun special-display-popup-frame (buffer &optional args)
"Display BUFFER and return the window chosen.
If BUFFER is already displayed in a visible or iconified frame,
raise that frame. Otherwise, display BUFFER in a new frame.
Optional argument ARGS is a list specifying additional
If ARGS is an alist, use it as a list of frame parameters. If
these parameters contain \(same-window . t), display BUFFER in
the selected window. If they contain \(same-frame . t), display
BUFFER in a window of the selected frame.
If ARGS is a list whose car is a symbol, use (car ARGS) as a
function to do the work. Pass it BUFFER as first argument,
and (cdr ARGS) as second."
(if (and args (symbolp (car args)))
(apply (car args) buffer (cdr args))
(let ((window (get-buffer-window buffer 0)))
;; If we have a window already, make it visible.
(when window
(let ((frame (window-frame window)))
(make-frame-visible frame)
(raise-frame frame)
;; Reuse the current window if the user requested it.
(when (cdr (assq 'same-window args))
(condition-case nil
(progn (switch-to-buffer buffer) (selected-window))
(error nil)))
;; Stay on the same frame if requested.
(when (or (cdr (assq 'same-frame args)) (cdr (assq 'same-window args)))
(let* ((pop-up-windows t)
special-display-buffer-names special-display-regexps)
(display-buffer buffer)))
;; If no window yet, make one in a new frame.
(let ((frame
(with-current-buffer buffer
(make-frame (append args special-display-frame-alist)))))
(set-window-buffer (frame-selected-window frame) buffer)
(set-window-dedicated-p (frame-selected-window frame) t)
(frame-selected-window frame))))))
(defun handle-delete-frame (event)
"Handle delete-frame events from the X server."
(interactive "e")
2011-06-21 Lars Magne Ingebrigtsen <>
* auth-source.el (auth-source-netrc-create): Don't print all tokens in
%S format, since that looks odd.
(auth-sources): Prefer the ~/.authinfo file over the ~/.authinfo.gpg
file, especially when saving.
2011-06-21 Andrew Cohen <>
* nnimap.el (nnimap-find-article-by-message-id): return nil when no
article found.
2011-06-18 Teodor Zlatanov <>
* auth-source.el (auth-source-netrc-use-gpg-tokens): Replace
......@@ -208,7 +208,7 @@ If the value is a function, debug messages are logged by calling
(function :tag "Function that takes arguments like `message'")
(const :tag "Don't log anything" nil)))
(defcustom auth-sources '("~/.authinfo.gpg" "~/.authinfo" "~/.netrc")
(defcustom auth-sources '("~/.authinfo" "~/.authinfo.gpg" "~/.netrc")
"List of authentication sources.
The default will get login and password information from
......@@ -713,7 +713,8 @@ Returns the deleted entries."
when (string-match (concat "^" auth-source-magic)
(symbol-name sym))
;; remove that key
do (password-cache-remove (symbol-name sym))))
do (password-cache-remove (symbol-name sym)))
(setq auth-source-netrc-cache nil))
(defun auth-source-remember (spec found)
"Remember FOUND search results for SPEC."
......@@ -1144,6 +1145,9 @@ See `auth-source-search' for details on SPEC."
;; we know (because of an assertion in auth-source-search) that the
;; :create parameter is either t or a list (which includes nil)
(create-extra (if (eq t create) nil create))
(current-data (car (auth-source-search :max 1
:host host
:port port)))
(required (append base-required create-extra))
(file (oref backend source))
(add "")
......@@ -1178,7 +1182,9 @@ See `auth-source-search' for details on SPEC."
(dolist (r required)
(let* ((data (aget valist r))
;; take the first element if the data is a list
(data (auth-source-netrc-element-or-first data))
(data (or (auth-source-netrc-element-or-first data)
(plist-get current-data
(intern (format ":%s" r) obarray))))
;; this is the default to be offered
(given-default (aget auth-source-creation-defaults r))
;; the default supplementals are simple:
......@@ -1281,7 +1287,7 @@ See `auth-source-search' for details on SPEC."
(let ((printer (lambda ()
;; append the key (the symbol name of r)
;; and the value in r
(format "%s%s %S"
(format "%s%s %s"
;; prepend a space
(if (zerop (length add)) "" " ")
;; remap auth-source tokens to netrc
......@@ -1291,8 +1297,9 @@ See `auth-source-search' for details on SPEC."
(secret "password")
(port "port") ; redundant but clearer
(t (symbol-name r)))
;; the value will be printed in %S format
(if (string-match "[\" ]" data)
(format "%S" data)
(setq add (concat add (funcall printer)))))))
......@@ -929,7 +929,7 @@ textual parts.")
(car (setq result (nnimap-parse-response))))
;; Select the last instance of the message in the group.
(and (setq article
(car (last (assoc "SEARCH" (cdr result)))))
(car (last (cdr (assoc "SEARCH" (cdr result))))))
(string-to-number article))))))
(defun nnimap-delete-article (articles)
This diff is collapsed.
......@@ -44,6 +44,7 @@
(require 'tls)
(require 'starttls)
(require 'auth-source)
(declare-function gnutls-negotiate "gnutls" t t) ; defun*
......@@ -110,10 +111,21 @@ values:
STARTTLS if the server supports STARTTLS, and nil otherwise.
:always-query-capabilies says whether to query the server for
capabilities, even if we're doing a `plain' network connection.
capabilities, even if we're doing a `plain' network connection.
:client-certificate should either be a list where the first
element is the certificate key file name, and the second
element is the certificate file name itself, or `t', which
means that `auth-source' will be queried for the key and the
certificate. This parameter will only be used when doing TLS
or STARTTLS connections.
If :use-starttls-if-possible is non-nil, do opportunistic
STARTTLS upgrades even if Emacs doesn't have built-in TLS
:nowait is a boolean that says the connection should be made
asynchronously, if possible."
asynchronously, if possible."
(unless (featurep 'make-network-process)
(error "Emacs was compiled without networking support"))
(let ((type (plist-get parameters :type))
......@@ -152,6 +164,22 @@ asynchronously, if possible."
:type (nth 3 result))
(car result))))))
(defun network-stream-certificate (host service parameters)
(let ((spec (plist-get :client-certificate parameters)))
((listp spec)
;; Either nil or a list with a key/certificate pair.
((eq spec t)
(let* ((auth-info
(car (auth-source-search :max 1
:host host
:port service)))
(key (plist-get auth-info :key))
(cert (plist-get auth-info :cert)))
(and key cert
(list key cert)))))))
(defalias 'open-protocol-stream 'open-network-stream)
......@@ -184,7 +212,8 @@ asynchronously, if possible."
;; If we have built-in STARTTLS support, try to upgrade the
;; connection.
(when (and (or (fboundp 'open-gnutls-stream)
(and require-tls
(and (or require-tls
(plist-get parameters :use-starttls-if-possible))
(executable-find "gnutls-cli")))
capabilities success-string starttls-function
(setq starttls-command
......@@ -201,14 +230,28 @@ asynchronously, if possible."
;; For opportunistic TLS upgrades, we don't really
;; care about the identity of the peer.
(cons "--insecure" starttls-extra-arguments))))
(cons "--insecure" starttls-extra-arguments)))
(cert (network-stream-certificate host service parameters)))
;; There are client certificates requested, so add them to
;; the command line.
(when cert
(setq starttls-extra-arguments
(nconc (list "--x509keyfile" (expand-file-name (nth 0 cert))
"--x509certfile" (expand-file-name (nth 1 cert)))
(setq stream (starttls-open-stream name buffer host service)))
(network-stream-get-response stream start eoc))
;; Requery capabilities for protocols that require it; i.e.,
;; EHLO for SMTP.
(when (plist-get parameters :always-query-capabilities)
(network-stream-command stream capability-command eoc))
(when (string-match success-string
(network-stream-command stream starttls-command eoc))
;; The server said it was OK to begin STARTTLS negotiations.
(if (fboundp 'open-gnutls-stream)
(gnutls-negotiate :process stream :hostname host)
(let ((cert (network-stream-certificate host service parameters)))
(gnutls-negotiate :process stream :hostname host
:keylist (and cert (list cert))))
(unless (starttls-negotiate stream)
(delete-process stream)))
(if (memq (process-status stream) '(open run))
......@@ -177,9 +177,9 @@ Remove also properties of all files in subdirectories."
(tramp-message vec 8 "%s" directory)
(lambda (key value)
(when (and (stringp (tramp-file-name-localname key))
(string-match directory (tramp-file-name-localname key)))
(remhash key tramp-cache-data)))
(when (and (stringp (tramp-file-name-localname key))
(string-match directory (tramp-file-name-localname key)))
(remhash key tramp-cache-data)))
;; Reverting or killing a buffer should also flush file properties.
......@@ -200,12 +200,12 @@ Remove also properties of all files in subdirectories."
(add-hook 'kill-buffer-hook 'tramp-flush-file-function)
(add-hook 'tramp-cache-unload-hook
(lambda ()
(remove-hook 'before-revert-hook
(remove-hook 'eshell-pre-command-hook
(remove-hook 'kill-buffer-hook
(remove-hook 'before-revert-hook
(remove-hook 'eshell-pre-command-hook
(remove-hook 'kill-buffer-hook
;;; -- Properties --
......@@ -290,17 +290,17 @@ KEY identifies the connection, it is either a process or a vector."
(let (result)
(lambda (key value)
(let ((tmp (format
"(%s %s)"
(if (processp key)
(prin1-to-string (prin1-to-string key))
(prin1-to-string key))
(if (hash-table-p value)
(tramp-cache-print value)
(if (bufferp value)
(prin1-to-string (prin1-to-string value))
(prin1-to-string value))))))
(setq result (if result (concat result " " tmp) tmp))))
(let ((tmp (format
"(%s %s)"
(if (processp key)
(prin1-to-string (prin1-to-string key))
(prin1-to-string key))
(if (hash-table-p value)
(tramp-cache-print value)
(if (bufferp value)
(prin1-to-string (prin1-to-string value))
(prin1-to-string value))))))
(setq result (if result (concat result " " tmp) tmp))))
......@@ -310,8 +310,8 @@ KEY identifies the connection, it is either a process or a vector."
(let (result)
(lambda (key value)
(when (and (vectorp key) (null (aref key 3)))
(add-to-list 'result key)))
(when (and (vectorp key) (null (aref key 3)))
(add-to-list 'result key)))
......@@ -327,12 +327,12 @@ KEY identifies the connection, it is either a process or a vector."
;; Remove temporary data.
(lambda (key value)
(if (and (vectorp key) (not (tramp-file-name-localname key)))
(remhash "process-name" value)
(remhash "process-buffer" value)
(remhash "first-password-request" value))
(remhash key cache)))
(if (and (vectorp key) (not (tramp-file-name-localname key)))
(remhash "process-name" value)
(remhash "process-buffer" value)
(remhash "first-password-request" value))
(remhash key cache)))
;; Dump it.
......@@ -357,8 +357,8 @@ KEY identifies the connection, it is either a process or a vector."
(add-hook 'kill-emacs-hook 'tramp-dump-connection-properties))
(add-hook 'tramp-cache-unload-hook
(lambda ()
(remove-hook 'kill-emacs-hook
(remove-hook 'kill-emacs-hook
(defun tramp-parse-connection-properties (method)
......@@ -368,18 +368,22 @@ for all methods. Resulting data are derived from connection history."
(let (res)
(lambda (key value)
(if (and (vectorp key)
(string-equal method (tramp-file-name-method key))
(not (tramp-file-name-localname key)))
(push (list (tramp-file-name-user key)
(tramp-file-name-host key))
(if (and (vectorp key)
(string-equal method (tramp-file-name-method key))
(not (tramp-file-name-localname key)))
(push (list (tramp-file-name-user key)
(tramp-file-name-host key))
;; Read persistent connection history.
(when (and (stringp tramp-persistency-file-name)
(zerop (hash-table-count tramp-cache-data)))
(zerop (hash-table-count tramp-cache-data))
;; When "emacs -Q" has been called, both variables are nil.
;; We do not load the persistency file then, in order to
;; have a clean test environment.
(or init-file-user site-run-file))
(condition-case err
(insert-file-contents tramp-persistency-file-name)
......@@ -916,6 +916,11 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
;; FIXME: This will surely lead to "MODIFIED OUTSIDE CUSTOM" warnings.
(menu-bar-mode (if (get-lisp-resource nil "Menus") 1 -1))
;; OS X Lion introduces PressAndHold, which is unsupported by this port.
;; See this thread for more details:
(ns-set-resource nil "ApplePressAndHoldEnabled" "NO")
(setq ns-initialized t))
(add-to-list 'handle-args-function-alist '(ns . x-handle-args))
......@@ -3014,7 +3014,11 @@ new window are inherited from the window selected on WINDOW's
frame. The selected window is not changed by this function."
(interactive "i")
(setq window (normalize-any-window window))
(let* ((horizontal (not (memq side '(nil below above))))
(let* ((side (cond
((not side) 'below)
((memq side '(below above right left)) side)
(t 'right)))
(horizontal (not (memq side '(nil below above))))
(frame (window-frame window))
(parent (window-parent window))
(function (window-parameter window 'split-window))
......@@ -3820,8 +3824,6 @@ subwindows can get as small as `window-safe-min-height' and
(pop-up-window-min-height . 40)
(pop-up-window-min-width . 80)
(reuse-window other nil nil)
(height . 24) (width . 80))
(reuse-window nil other visible)
(reuse-window nil nil t)
(reuse-window-even-sizes . t))
......@@ -4371,8 +4373,7 @@ using the location specifiers `same-window' or `other-frame'."
:tag "Pop-up frame"
:value (pop-up-frame
(pop-up-frame-alist (height . 24) (width . 80)))
:format "%t\n%v"
:inline t
(const :format "" pop-up-frame)
2011-06-22 Paul Eggert <>
Integer overflow and signedness fixes (Bug#8873).
A few related buffer overrun fixes, too.
* font.c (font_score): Use EMACS_INT, not int, to store XINT value.
* dispextern.h (struct face.stipple):
* image.c (x_bitmap_height, x_bitmap_width, x_bitmap_pixmap)
(x_bitmap_mask, x_allocate_bitmap_record)
(x_create_bitmap_from_data, x_create_bitmap_from_file)
(x_destroy_bitmap, x_destroy_all_bitmaps, x_create_bitmap_mask)
* nsterm.h (struct ns_display_info.bitmaps_size, .bitmaps_last):
* w32term.h (struct w32_display_info.icon_bitmap_id, .bitmaps_size)
* xfaces.c (load_pixmap):
* xterm.c (x_bitmap_icon, x_wm_set_icon_pixmap):
* xterm.h (struct x_display_info.icon_bitmap_id, .bitmaps_size)
(.bitmaps_last, struct x_output.icon_bitmap):
Use ptrdiff_t, not int, for bitmap indexes.
(x_allocate_bitmap_record): Check for size overflow.
* dispextern.h, lisp.h: Adjust to API changes elsewhere.
Use ptrdiff_t, not int, for overlay counts.
* buffer.h (overlays_at, sort_overlays, GET_OVERLAYS_AT):
* editfns.c (overlays_around, get_pos_property):
* textprop.c (get_char_property_and_overlay):
* xdisp.c (next_overlay_change, note_mouse_highlight):
* xfaces.c (face_at_buffer_position):
* buffer.c (OVERLAY_COUNT_MAX): New macro.
(overlays_at, overlays_in, sort_overlays, Foverlays_at)
(Fnext_overlay_change, Fprevious_overlay_change)
(mouse_face_overlay_overlaps, Foverlays_in):
Use ptrdiff_t, not int, for sizes.
(overlays_at, overlays_in): Check for size-calculation overflow.
* xterm.c (xim_initialize, same_x_server): Strlen may not fit in int.
* xsmfns.c (smc_save_yourself_CB, x_session_initialize): Avoid strlen.
(x_session_initialize): Do not assume string length fits in int.
* xsettings.c (apply_xft_settings): Fix potential buffer overrun.
This is unlikely, but can occur if DPI is outlandish.
* xsettings.c (Ffont_get_system_normal_font, Ffont_get_system_font):
* xselect.c (Fx_get_atom_name): Avoid need for strlen.
* xrdb.c: Don't assume strlen fits in int; avoid some strlens.
* xrdb.c (magic_file_p, search_magic_path):
Omit last arg SUFFIX; it was always 0. All callers changed.
(magic_file_p): Use ptrdiff_t, not int. Check for size overflow.
* xfont.c (xfont_match): Avoid need for strlen.
* xfns.c: Don't assume strlen fits in int.
(xic_create_fontsetname, x_window): Use ptrdiff_t, not int.
* xdisp.c (message_log_check_duplicate): Return intmax_t,
not unsigned long, as we prefer signed integers. All callers changed.
Detect integer overflow in repeat count.
(message_dolog): Don't assume print length fits in 39 bytes.
(display_mode_element): Don't assume strlen fits in int.
* termcap.c: Don't assume sizes fit in int and never overflow.
(struct termcap_buffer, tgetent): Use ptrdiff_t, not int, for sizes.
(gobble_line): Check for size-calculation overflow.
* minibuf.c (Fread_buffer):
* lread.c (intern, intern_c_string):
* image.c (xpm_scan) [HAVE_NS && !HAVE_XPM]:
Don't assume string length fits in int.
* keyboard.c (parse_tool_bar_item):
* gtkutil.c (style_changed_cb): Avoid need for strlen.
* font.c: Don't assume string length fits in int.
(font_parse_xlfd, font_parse_fcname, font_unparse_fcname):
Use ptrdiff_t, not int.
(font_intern_prop): Don't assume string length fits in int.
Don't assume integer property fits in fixnum.
* font.h (font_intern_prop): 2nd arg is now ptrdiff_t, not int.
* filelock.c: Fix some buffer overrun and integer overflow issues.
(get_boot_time): Don't assume gzip command string fits in 100 bytes.