summaryrefslogtreecommitdiff
path: root/lisp/mail
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mail')
-rw-r--r--lisp/mail/binhex.el50
-rw-r--r--lisp/mail/blessmail.el6
-rw-r--r--lisp/mail/emacsbug.el100
-rw-r--r--lisp/mail/feedmail.el103
-rw-r--r--lisp/mail/flow-fill.el74
-rw-r--r--lisp/mail/footnote.el853
-rw-r--r--lisp/mail/hashcash.el20
-rw-r--r--lisp/mail/ietf-drums.el26
-rw-r--r--lisp/mail/mail-extr.el22
-rw-r--r--lisp/mail/mail-utils.el2
-rw-r--r--lisp/mail/mailabbrev.el15
-rw-r--r--lisp/mail/mailalias.el12
-rw-r--r--lisp/mail/mailheader.el3
-rw-r--r--lisp/mail/mspools.el3
-rw-r--r--lisp/mail/qp.el3
-rw-r--r--lisp/mail/rfc2047.el26
-rw-r--r--lisp/mail/rfc2231.el8
-rw-r--r--lisp/mail/rmail-spam-filter.el2
-rw-r--r--lisp/mail/rmail.el83
-rw-r--r--lisp/mail/rmailmm.el3
-rw-r--r--lisp/mail/rmailout.el70
-rw-r--r--lisp/mail/rmailsum.el26
-rw-r--r--lisp/mail/sendmail.el122
-rw-r--r--lisp/mail/smtpmail.el188
-rw-r--r--lisp/mail/supercite.el20
-rw-r--r--lisp/mail/uce.el2
-rw-r--r--lisp/mail/uudecode.el62
-rw-r--r--lisp/mail/yenc.el8
28 files changed, 997 insertions, 915 deletions
diff --git a/lisp/mail/binhex.el b/lisp/mail/binhex.el
index eb00b87f4c1..1cf50aa0678 100644
--- a/lisp/mail/binhex.el
+++ b/lisp/mail/binhex.el
@@ -1,4 +1,4 @@
-;;; binhex.el --- decode BinHex-encoded text
+;;; binhex.el --- decode BinHex-encoded text -*- lexical-binding:t -*-
;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
@@ -29,8 +29,6 @@
;;; Code:
-(eval-when-compile (require 'cl))
-
(eval-and-compile
(defalias 'binhex-char-int
(if (fboundp 'char-int)
@@ -90,16 +88,12 @@ input and write the converted data to its standard output."
((boundp 'temporary-file-directory) temporary-file-directory)
("/tmp/")))
-(eval-and-compile
- (defalias 'binhex-insert-char
- (if (featurep 'xemacs)
- 'insert-char
- (lambda (char &optional count ignored buffer)
- "Insert COUNT copies of CHARACTER into BUFFER."
- (if (or (null buffer) (eq buffer (current-buffer)))
- (insert-char char count)
- (with-current-buffer buffer
- (insert-char char count)))))))
+(defun binhex-insert-char (char &optional count ignored buffer)
+ "Insert COUNT copies of CHARACTER into BUFFER."
+ (if (or (null buffer) (eq buffer (current-buffer)))
+ (insert-char char count)
+ (with-current-buffer buffer
+ (insert-char char count))))
(defvar binhex-crc-table
[0 4129 8258 12387 16516 20645 24774 28903
@@ -138,9 +132,9 @@ input and write the converted data to its standard output."
(defun binhex-update-crc (crc char &optional count)
(if (null count) (setq count 1))
(while (> count 0)
- (setq crc (logxor (logand (lsh crc 8) 65280)
+ (setq crc (logxor (logand (ash crc 8) 65280)
(aref binhex-crc-table
- (logxor (logand (lsh crc -8) 255)
+ (logxor (logand (ash crc -8) 255)
char)))
count (1- count)))
crc)
@@ -158,14 +152,14 @@ input and write the converted data to its standard output."
(defun binhex-string-big-endian (string)
(let ((ret 0) (i 0) (len (length string)))
(while (< i len)
- (setq ret (+ (lsh ret 8) (binhex-char-int (aref string i)))
+ (setq ret (+ (ash ret 8) (binhex-char-int (aref string i)))
i (1+ i)))
ret))
(defun binhex-string-little-endian (string)
(let ((ret 0) (i 0) (shift 0) (len (length string)))
(while (< i len)
- (setq ret (+ ret (lsh (binhex-char-int (aref string i)) shift))
+ (setq ret (+ ret (ash (binhex-char-int (aref string i)) shift))
i (1+ i)
shift (+ shift 8)))
ret))
@@ -193,7 +187,7 @@ input and write the converted data to its standard output."
(defvar binhex-last-char)
(defvar binhex-repeat)
-(defun binhex-push-char (char &optional count ignored buffer)
+(defun binhex-push-char (char &optional ignored buffer)
(cond
(binhex-repeat
(if (eq char 0)
@@ -226,8 +220,8 @@ If HEADER-ONLY is non-nil only decode header and return filename."
(goto-char start)
(when (re-search-forward binhex-begin-line end t)
(setq work-buffer (generate-new-buffer " *binhex-work*"))
- (unless (featurep 'xemacs)
- (with-current-buffer work-buffer (set-buffer-multibyte nil)))
+ (with-current-buffer work-buffer
+ (set-buffer-multibyte nil))
(beginning-of-line)
(setq bits 0 counter 0)
(while tmp
@@ -241,13 +235,13 @@ If HEADER-ONLY is non-nil only decode header and return filename."
counter (1+ counter)
inputpos (1+ inputpos))
(cond ((= counter 4)
- (binhex-push-char (lsh bits -16) 1 nil work-buffer)
- (binhex-push-char (logand (lsh bits -8) 255) 1 nil
+ (binhex-push-char (ash bits -16) nil work-buffer)
+ (binhex-push-char (logand (ash bits -8) 255) nil
work-buffer)
- (binhex-push-char (logand bits 255) 1 nil
+ (binhex-push-char (logand bits 255) nil
work-buffer)
(setq bits 0 counter 0))
- (t (setq bits (lsh bits 6)))))
+ (t (setq bits (ash bits 6)))))
(if (null file-name-length)
(with-current-buffer work-buffer
(setq file-name-length (char-after (point-min))
@@ -263,12 +257,12 @@ If HEADER-ONLY is non-nil only decode header and return filename."
(setq tmp (and tmp (not (eq inputpos end)))))
(cond
((= counter 3)
- (binhex-push-char (logand (lsh bits -16) 255) 1 nil
+ (binhex-push-char (logand (ash bits -16) 255) nil
work-buffer)
- (binhex-push-char (logand (lsh bits -8) 255) 1 nil
+ (binhex-push-char (logand (ash bits -8) 255) nil
work-buffer))
((= counter 2)
- (binhex-push-char (logand (lsh bits -10) 255) 1 nil
+ (binhex-push-char (logand (ash bits -10) 255) nil
work-buffer))))
(if header-only nil
(binhex-verify-crc work-buffer
@@ -287,7 +281,7 @@ If HEADER-ONLY is non-nil only decode header and return filename."
(defun binhex-decode-region-external (start end)
"Binhex decode region between START and END using external decoder."
(interactive "r")
- (let ((cbuf (current-buffer)) firstline work-buffer status
+ (let ((cbuf (current-buffer)) firstline work-buffer
(file-name (expand-file-name
(concat (binhex-decode-region-internal start end t)
".data")
diff --git a/lisp/mail/blessmail.el b/lisp/mail/blessmail.el
index 42c60c3f6c3..62094bfe2d7 100644
--- a/lisp/mail/blessmail.el
+++ b/lisp/mail/blessmail.el
@@ -49,15 +49,15 @@
(setq attr (file-attributes dirname))
(if (not (eq t (car attr)))
(insert (format "echo %s is not a directory\n" rmail-spool-directory))
- (setq modes (nth 8 attr))
+ (setq modes (file-attribute-modes attr))
(cond ((= ?w (aref modes 8))
;; Nothing needs to be done.
)
((= ?w (aref modes 5))
- (insert "chgrp " (number-to-string (nth 3 attr))
+ (insert "chgrp " (number-to-string (file-attribute-group-id attr))
" $* && chmod g+s $*\n"))
((= ?w (aref modes 2))
- (insert "chown " (number-to-string (nth 2 attr))
+ (insert "chown " (number-to-string (file-attribute-user-id attr))
" $* && chmod u+s $*\n"))
(t
(insert "chown root $* && chmod u+s $*\n"))))
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index 859239405a9..c637e242c42 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -69,6 +69,7 @@
(declare-function x-server-vendor "xfns.c" (&optional terminal))
(declare-function x-server-version "xfns.c" (&optional terminal))
(declare-function message-sort-headers "message" ())
+(declare-function w32--os-description "w32-fns" ())
(defvar message-strip-special-text-properties)
(defun report-emacs-bug-can-use-osx-open ()
@@ -116,6 +117,88 @@ This requires either the macOS \"open\" command, or the freedesktop
(concat "mailto:" to)))
(error "Subject, To or body not found")))))
+(defvar report-emacs-bug--os-description nil
+ "Cached value of operating system description.")
+
+(defun report-emacs-bug--os-description ()
+ "Return a string describing the operating system, or nil."
+ (cond ((eq system-type 'darwin)
+ (let (os)
+ (with-temp-buffer
+ (when (eq 0 (ignore-errors
+ (call-process "sw_vers" nil '(t nil) nil)))
+ (dolist (s '("ProductName" "ProductVersion"))
+ (goto-char (point-min))
+ (if (re-search-forward (format "^%s\\s-*:\\s-+\\(.*\\)$" s)
+ nil t)
+ (setq os (concat os " " (match-string 1)))))))
+ os))
+ ((eq system-type 'windows-nt)
+ (or report-emacs-bug--os-description
+ (setq report-emacs-bug--os-description (w32--os-description))))
+ ((eq system-type 'berkeley-unix)
+ (with-temp-buffer
+ (when
+ (or (eq 0 (ignore-errors (call-process "freebsd-version" nil
+ '(t nil) nil "-u")))
+ (progn (erase-buffer)
+ (eq 0 (ignore-errors
+ (call-process "uname" nil
+ '(t nil) nil "-a")))))
+ (unless (zerop (buffer-size))
+ (goto-char (point-min))
+ (buffer-substring (line-beginning-position)
+ (line-end-position))))))
+ ;; TODO Cygwin, Solaris (usg-unix-v).
+ (t
+ (or (let ((file "/etc/os-release"))
+ (and (file-readable-p file)
+ (with-temp-buffer
+ (insert-file-contents file)
+ (if (re-search-forward
+ "^\\sw*PRETTY_NAME=\"?\\(.+?\\)\"?$" nil t)
+ (match-string 1)
+ (let (os)
+ (when (re-search-forward
+ "^\\sw*NAME=\"?\\(.+?\\)\"?$" nil t)
+ (setq os (match-string 1))
+ (if (re-search-forward
+ "^\\sw*VERSION=\"?\\(.+?\\)\"?$" nil t)
+ (setq os (concat os " " (match-string 1))))
+ os))))))
+ (with-temp-buffer
+ (when (eq 0 (ignore-errors
+ (call-process "lsb_release" nil '(t nil)
+ nil "-d")))
+ (goto-char (point-min))
+ (if (looking-at "^\\sw+:\\s-+")
+ (goto-char (match-end 0)))
+ (buffer-substring (point) (line-end-position))))
+ (let ((file "/etc/lsb-release"))
+ (and (file-readable-p file)
+ (with-temp-buffer
+ (insert-file-contents file)
+ (if (re-search-forward
+ "^\\sw*DISTRIB_DESCRIPTION=\"?\\(.*release.*?\\)\"?$" nil t)
+ (match-string 1)))))
+ (catch 'found
+ (dolist (f (append (file-expand-wildcards "/etc/*-release")
+ '("/etc/debian_version")))
+ (and (not (member (file-name-nondirectory f)
+ '("lsb-release" "os-release")))
+ (file-readable-p f)
+ (with-temp-buffer
+ (insert-file-contents f)
+ (if (not (zerop (buffer-size)))
+ (throw 'found
+ (format "%s%s"
+ (if (equal (file-name-nondirectory f)
+ "debian_version")
+ "Debian " "")
+ (buffer-substring
+ (line-beginning-position)
+ (line-end-position)))))))))))))
+
;; It's the default mail mode, so it seems OK to use its features.
(autoload 'message-bogus-recipient-p "message")
(autoload 'message-make-address "message")
@@ -225,6 +308,8 @@ usually do not have translators for other languages.\n\n")))
(if (stringp emacs-repository-version)
(insert "Repository revision: " emacs-repository-version "\n"))
+ (if (stringp emacs-repository-branch)
+ (insert "Repository branch: " emacs-repository-branch "\n"))
(if (fboundp 'x-server-vendor)
(condition-case nil
;; This is used not only for X11 but also W32 and others.
@@ -232,13 +317,9 @@ usually do not have translators for other languages.\n\n")))
"', version "
(mapconcat 'number-to-string (x-server-version) ".") "\n")
(error t)))
- (let ((lsb (with-temp-buffer
- (if (eq 0 (ignore-errors
- (call-process "lsb_release" nil '(t nil)
- nil "-d")))
- (buffer-string)))))
- (if (stringp lsb)
- (insert "System " lsb "\n")))
+ (let ((os (ignore-errors (report-emacs-bug--os-description))))
+ (if (stringp os)
+ (insert "System Description: " os "\n\n")))
(let ((message-buf (get-buffer "*Messages*")))
(if message-buf
(let (beg-pos
@@ -267,11 +348,6 @@ usually do not have translators for other languages.\n\n")))
"LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES"
"LC_MONETARY" "LC_NUMERIC" "LC_TIME" "LANG" "XMODIFIERS"))
(insert (format " locale-coding-system: %s\n" locale-coding-system))
- ;; Only ~ 0.2% of people from a sample of 3200 changed this from
- ;; the default, t.
- (or (default-value 'enable-multibyte-characters)
- (insert (format " default enable-multibyte-characters: %s\n"
- (default-value 'enable-multibyte-characters))))
(insert "\n")
(insert (format "Major mode: %s\n"
(format-mode-line
diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el
index 27ebe162491..babc3fc212a 100644
--- a/lisp/mail/feedmail.el
+++ b/lisp/mail/feedmail.el
@@ -1,5 +1,6 @@
-;;; feedmail.el --- assist other email packages to massage outgoing messages
-;;; This file is in the public domain.
+;;; feedmail.el --- assist other email packages to massage outgoing messages -*- lexical-binding:t -*-
+
+;; This file is in the public domain.
;; This file is part of GNU Emacs.
@@ -1312,25 +1313,21 @@ There's no trivial way to avoid it. It's unwise to just set the value
of `buffer-file-name' to nil because that will defeat feedmail's file
management features. Instead, arrange for this variable to be set to
the value of `buffer-file-name' before setting that to nil. An easy way
-to do that would be with defadvice on `mail-send' \(undoing the
-assignments in a later advice).
+to do that would be with an advice on `mail-send'.
feedmail will pretend that `buffer-file-name', if nil, has the value
assigned of `feedmail-queue-buffer-file-name' and carry out its normal
activities. feedmail does not restore the non-nil value of
-`buffer-file-name'. For safe bookkeeping, the user should insure that
+`buffer-file-name'. For safe bookkeeping, the user should ensure that
feedmail-queue-buffer-file-name is restored to nil.
-Example `defadvice' for mail-send:
-
- (defadvice mail-send (before feedmail-mail-send-before-advice activate)
- (setq feedmail-queue-buffer-file-name buffer-file-name)
- (setq buffer-file-name nil))
+Example advice for mail-send:
- (defadvice mail-send (after feedmail-mail-send-after-advice activate)
- (if feedmail-queue-buffer-file-name (setq buffer-file-name feedmail-queue-buffer-file-name))
- (setq feedmail-queue-buffer-file-name nil))
-")
+ (advice-add 'mail-send :around #'my-feedmail-mail-send-advice)
+ (defun my-feedmail-mail-send-advice (orig-fun &rest args)
+ (let ((feedmail-queue-buffer-file-name buffer-file-name)
+ (buffer-file-name nil))
+ (apply orig-fun args)))")
;; defvars to make byte-compiler happy(er)
(defvar feedmail-error-buffer nil)
@@ -1396,7 +1393,7 @@ It shows the simple addresses and gets a confirmation. Use as:
When this hook runs, the current buffer is already the appropriate
buffer. It has already had all the header prepping from the standard
package. The next step after running the hook will be to save the
-message via FCC: processing. The hook might be interested in these:
+message via Fcc: processing. The hook might be interested in these:
\(1) `feedmail-prepped-text-buffer' contains the header and body of the
message, ready to go; (2) `feedmail-address-list' contains a list
of simplified recipients of addresses which are to be given to the
@@ -1438,7 +1435,7 @@ internal buffers will be reused and things will get confused."
)
(defcustom feedmail-queue-runner-mode-setter
- (lambda (&optional arg) (mail-mode))
+ (lambda (&optional _) (mail-mode))
"A function to set the proper mode of a message file.
Called when the message is read back out of the queue directory with a single
argument, the optional argument used in the call to
@@ -1474,7 +1471,10 @@ set `mail-header-separator' to the value of
(defcustom feedmail-queue-runner-message-sender
- (lambda (&optional arg) (mail-send))
+ (lambda (&optional _)
+ ;; `mail-send' is not autoloaded, which is why we need the `require'.
+ (require 'sendmail) (declare-function mail-send "sendmail")
+ (mail-send))
"Function to initiate sending a message file.
Called for each message read back out of the queue directory with a
single argument, the optional argument used in the call to
@@ -1607,7 +1607,7 @@ Feeds the buffer to it."
"Function which actually calls sendmail as a subprocess.
Feeds the buffer to it. Probably has some flaws for Resent-* and other
complicated cases. Takes addresses from message headers and
-might disappoint you with BCC: handling. In case of odd results, consult
+might disappoint you with Bcc: handling. In case of odd results, consult
local gurus."
(require 'sendmail)
(feedmail-say-debug ">in-> feedmail-buffer-to-sendmail %s" addr-listoid)
@@ -1657,7 +1657,7 @@ local gurus."
(declare-function smtp-via-smtp "ext:smtp" (sender recipients smtp-text-buffer))
(defvar smtp-server)
-;; FLIM's smtp.el pointed out to me by Kenichi Handa <handa@etl.go.jp>
+;; FLIM's smtp.el pointed out to me by Kenichi Handa <handa@gnu.org>
(defun feedmail-buffer-to-smtp (prepped errors-to addr-listoid)
"Function which actually calls smtp-via-smtp to send buffer as e-mail."
(feedmail-say-debug ">in-> feedmail-buffer-to-smtp %s" addr-listoid)
@@ -1737,7 +1737,7 @@ insertion.")
(declare-function vm-mail "ext:vm" (&optional to subject))
-(defun feedmail-vm-mail-mode (&optional arg)
+(defun feedmail-vm-mail-mode (&optional _)
"Make something like a buffer that has been created via `vm-mail'.
The optional argument is ignored and is just for argument compatibility with
`feedmail-queue-runner-mode-setter'. This function is suitable for being
@@ -1745,9 +1745,7 @@ applied to a file after you've just read it from disk: for example, a
feedmail FQM message file from a queue. You could use something like
this:
-\(setq auto-mode-alist
- (cons \\='(\"\\\\.fqm$\" . feedmail-vm-mail-mode) auto-mode-alist))
-"
+ (add-to-list 'auto-mode-alist \\='(\"\\\\.fqm\\\\\\='\" . feedmail-vm-mail-mode))"
(feedmail-say-debug ">in-> feedmail-vm-mail-mode")
(let ((the-buf (current-buffer)))
(vm-mail)
@@ -2150,19 +2148,8 @@ you can set `feedmail-queue-reminder-alist' to nil."
feedmail-prompt-before-queue-user-alist
))
-(defun feedmail-queue-runner-prompt ()
- "Ask whether to queue, send immediately, or return to editing a message, etc."
- (feedmail-say-debug ">in-> feedmail-queue-runner-prompt")
- (feedmail-queue-send-edit-prompt-inner
- feedmail-ask-before-queue-default
- feedmail-ask-before-queue-prompt
- feedmail-ask-before-queue-reprompt
- 'feedmail-message-action-help
- feedmail-prompt-before-queue-standard-alist
- feedmail-prompt-before-queue-user-alist
- ))
(defun feedmail-queue-send-edit-prompt-inner (default prompt reprompt helper
- standard-alist user-alist)
+ standard-alist user-alist)
(feedmail-say-debug ">in-> feedmail-queue-send-edit-prompt-inner")
;; Some implementation ideas here came from the userlock.el code
(or defining-kbd-macro (discard-input))
@@ -2181,7 +2168,7 @@ you can set `feedmail-queue-reminder-alist' to nil."
(let ((inhibit-quit t) (cursor-in-echo-area t) (echo-keystrokes 0))
(read-char-exclusive))))
(if (= user-sez help-char)
- (setq answer '(^ . helper))
+ (setq answer (cons '^ helper))
(if (or (eq user-sez ?\C-m) (eq user-sez ?\C-j) (eq user-sez ?y))
(setq user-sez d-char))
;; these char-to-int things are because of some
@@ -2209,8 +2196,7 @@ you can set `feedmail-queue-reminder-alist' to nil."
;; emacs convention is that scroll-up moves text up, window down
(feedmail-say-debug ">in-> feedmail-scroll-buffer %s" direction)
(save-selected-window
- (let ((signal-error-on-buffer-boundary nil)
- (fqm-window (display-buffer (if buffy buffy (current-buffer)))))
+ (let ((fqm-window (display-buffer (if buffy buffy (current-buffer)))))
(select-window fqm-window)
(if (eq direction 'up)
(if (pos-visible-in-window-p (point-max) fqm-window)
@@ -2380,7 +2366,7 @@ mapped to mostly alphanumerics for safety."
(defun feedmail-rfc822-date (arg-time)
(feedmail-say-debug ">in-> feedmail-rfc822-date %s" arg-time)
- (let ((time (if arg-time arg-time (current-time)))
+ (let ((time (or arg-time (current-time)))
(system-time-locale "C"))
(concat
(format-time-string "%a, %e %b %Y %T " time)
@@ -2697,8 +2683,10 @@ fiddle-plex, as described in the documentation for the variable
(save-excursion
(if feedmail-enable-spray
(mapcar
- (lambda (feedmail-spray-this-address)
- (let ((spray-buffer (get-buffer-create " *FQM Outgoing Email Spray*")))
+ (lambda (address)
+ (let ((feedmail-spray-this-address address)
+ (spray-buffer
+ (get-buffer-create " *FQM Outgoing Email Spray*")))
(with-current-buffer spray-buffer
(erase-buffer)
;; not life's most efficient methodology, but spraying isn't
@@ -2712,7 +2700,8 @@ fiddle-plex, as described in the documentation for the variable
;; Message-Id:s, but I doubt that anyone cares,
;; practically. If someone complains about it, I'll
;; add it.
- (feedmail-fiddle-list-of-spray-fiddle-plexes feedmail-spray-address-fiddle-plex-list)
+ (feedmail-fiddle-list-of-spray-fiddle-plexes
+ feedmail-spray-address-fiddle-plex-list)
;; this (let ) is just in case some buffer eater
;; is cheating and using the global variable name instead
;; of its argument to find the buffer
@@ -2823,16 +2812,13 @@ return that value."
(defun feedmail-default-date-generator (maybe-file)
"Default function for generating Date: header contents."
(feedmail-say-debug ">in-> feedmail-default-date-generator")
- (when maybe-file
- (feedmail-say-debug (concat "4 cre " (feedmail-rfc822-date (nth 4 (file-attributes maybe-file)))))
- (feedmail-say-debug (concat "5 mod " (feedmail-rfc822-date (nth 5 (file-attributes maybe-file)))))
- (feedmail-say-debug (concat "6 sta " (feedmail-rfc822-date (nth 6 (file-attributes maybe-file))))))
- (let ((date-time))
- (if (and (not feedmail-queue-use-send-time-for-date) maybe-file)
- (setq date-time (nth 5 (file-attributes maybe-file))))
- (feedmail-rfc822-date date-time))
- )
-
+ (let ((attr (and maybe-file (file-attributes maybe-file))))
+ (when attr
+ (feedmail-say-debug (concat "4 cre " (feedmail-rfc822-date (file-attribute-access-time attr))))
+ (feedmail-say-debug (concat "5 mod " (feedmail-rfc822-date (file-attribute-modification-time attr))))
+ (feedmail-say-debug (concat "6 sta " (feedmail-rfc822-date (file-attribute-status-change-time attr)))))
+ (feedmail-rfc822-date (and attr (not feedmail-queue-use-send-time-for-date)
+ (file-attribute-modification-time attr)))))
(defun feedmail-fiddle-date (maybe-file)
"Fiddle Date:. See documentation of `feedmail-date-generator'."
@@ -2882,7 +2868,8 @@ probably not appropriate for you."
(concat (if (equal (match-beginning 1) (match-end 1)) "" "-") end-stuff))
(setq end-stuff (concat "@" end-stuff)))
(if (and (not feedmail-queue-use-send-time-for-message-id) maybe-file)
- (setq date-time (nth 5 (file-attributes maybe-file))))
+ (setq date-time (file-attribute-modification-time
+ (file-attributes maybe-file))))
(format "<%d-%s%s%s>"
(mod (random) 10000)
(format-time-string "%a%d%b%Y%H%M%S" date-time)
@@ -3147,13 +3134,17 @@ been weeded out."
(identity address-list)))
-(defun feedmail-one-last-look (feedmail-prepped-text-buffer)
+(defun feedmail-one-last-look (buffer)
"Offer the user one last chance to give it up."
(feedmail-say-debug ">in-> feedmail-one-last-look")
(save-excursion
+ ;; FIXME: switch-to-buffer may fail or pop up a new frame
+ ;; (in minibuffer-only frames, for example) and save-window-excursion
+ ;; won't delete the newly created frame upon exit!
(save-window-excursion
- (switch-to-buffer feedmail-prepped-text-buffer)
- (if (and (fboundp 'y-or-n-p-with-timeout) (numberp feedmail-confirm-outgoing-timeout))
+ (switch-to-buffer buffer)
+ (if (and (fboundp 'y-or-n-p-with-timeout)
+ (numberp feedmail-confirm-outgoing-timeout))
(y-or-n-p-with-timeout
"FQM: Send this email? "
(abs feedmail-confirm-outgoing-timeout)
diff --git a/lisp/mail/flow-fill.el b/lisp/mail/flow-fill.el
index 8451315a12e..ed6a2df87dc 100644
--- a/lisp/mail/flow-fill.el
+++ b/lisp/mail/flow-fill.el
@@ -1,4 +1,4 @@
-;;; flow-fill.el --- interpret RFC2646 "flowed" text
+;;; flow-fill.el --- interpret RFC2646 "flowed" text -*- lexical-binding:t -*-
;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
@@ -49,7 +49,6 @@
;;; Code:
-(eval-when-compile (require 'cl))
(defcustom fill-flowed-display-column 'fill-column
"Column beyond which format=flowed lines are wrapped, when displayed.
@@ -166,74 +165,15 @@ RFC 2646 suggests 66 characters for readability."
(forward-line 1)
nil))))))))
-;; Test vectors.
-
-(defvar show-trailing-whitespace)
-
-(defvar fill-flowed-encode-tests
- `(
- ;; The syntax of each list element is:
- ;; (INPUT . EXPECTED-OUTPUT)
- (,(concat
- "> Thou villainous ill-breeding spongy dizzy-eyed \n"
- "> reeky elf-skinned pigeon-egg! \n"
- ">> Thou artless swag-bellied milk-livered \n"
- ">> dismal-dreaming idle-headed scut!\n"
- ">>> Thou errant folly-fallen spleeny reeling-ripe \n"
- ">>> unmuzzled ratsbane!\n"
- ">>>> Henceforth, the coding style is to be strictly \n"
- ">>>> enforced, including the use of only upper case.\n"
- ">>>>> I've noticed a lack of adherence to the coding \n"
- ">>>>> styles, of late.\n"
- ">>>>>> Any complaints?")
- .
- ,(concat
- "> Thou villainous ill-breeding spongy dizzy-eyed reeky elf-skinned\n"
- "> pigeon-egg! \n"
- ">> Thou artless swag-bellied milk-livered dismal-dreaming idle-headed\n"
- ">> scut!\n"
- ">>> Thou errant folly-fallen spleeny reeling-ripe unmuzzled ratsbane!\n"
- ">>>> Henceforth, the coding style is to be strictly enforced,\n"
- ">>>> including the use of only upper case.\n"
- ">>>>> I've noticed a lack of adherence to the coding styles, of late.\n"
- ">>>>>> Any complaints?\n"
- ))
- ;; (,(concat
- ;; "\n"
- ;; "> foo\n"
- ;; "> \n"
- ;; "> \n"
- ;; "> bar\n")
- ;; .
- ;; ,(concat
- ;; "\n"
- ;; "> foo bar\n"))
- ))
+(make-obsolete-variable 'fill-flowed-encode-tests nil "27.1")
+(defvar fill-flowed-encode-tests)
(defun fill-flowed-test ()
(interactive "")
- (switch-to-buffer (get-buffer-create "*Format=Flowed test output*"))
- (erase-buffer)
- (setq show-trailing-whitespace t)
- (dolist (test fill-flowed-encode-tests)
- (let (start output)
- (insert "***** BEGIN TEST INPUT *****\n")
- (insert (car test))
- (insert "***** END TEST INPUT *****\n\n")
- (insert "***** BEGIN TEST OUTPUT *****\n")
- (setq start (point))
- (insert (car test))
- (save-restriction
- (narrow-to-region start (point))
- (fill-flowed))
- (setq output (buffer-substring start (point-max)))
- (insert "***** END TEST OUTPUT *****\n")
- (unless (string= output (cdr test))
- (insert "\n***** BEGIN TEST EXPECTED OUTPUT *****\n")
- (insert (cdr test))
- (insert "***** END TEST EXPECTED OUTPUT *****\n"))
- (insert "\n\n")))
- (goto-char (point-max)))
+ (declare (obsolete nil "27.1"))
+ (user-error (concat "This function is obsolete. Please see "
+ "test/lisp/mail/flow-fill-tests.el "
+ "in the Emacs source tree")))
(provide 'flow-fill)
diff --git a/lisp/mail/footnote.el b/lisp/mail/footnote.el
index be3a878f832..bbc42e11f74 100644
--- a/lisp/mail/footnote.el
+++ b/lisp/mail/footnote.el
@@ -1,8 +1,9 @@
-;;; footnote.el --- footnote support for message mode
+;;; footnote.el --- footnote support for message mode -*- lexical-binding:t -*-
;; Copyright (C) 1997, 2000-2019 Free Software Foundation, Inc.
-;; Author: Steven L Baur <steve@xemacs.org>
+;; Author: Steven L Baur <steve@xemacs.org> (1997-2011)
+;; Boruch Baum <boruch_baum@gmx.com> (2017-)
;; Keywords: mail, news
;; Version: 0.19
@@ -29,9 +30,36 @@
;; [1] Footnotes look something like this. Along with some decorative
;; stuff.
-;; TODO:
-;; Reasonable Undo support.
-;; more language styles.
+;;;; TODO:
+;; + Reasonable Undo support.
+;; - could use an `apply' entry in the buffer-undo-list to be warned when
+;; a footnote we inserted is removed via undo.
+;; - should try to handle the more general problem of deleting/removing
+;; footnotes via standard editing commands rather than via footnote
+;; commands.
+;; + more language styles.
+;; + The key sequence 'C-c ! a C-y C-c ! b' should auto-fill the
+;; footnote in adaptive fill mode. This does not seem to be a bug in
+;; `adaptive-fill' because it behaves that way on all point movements
+;; + Handle footmode mode elegantly in all modes, even if that means refuses to
+;; accept the burden. For example, in a programming language mode, footnotes
+;; should be commented.
+;; + Manually autofilling the a first footnote should not cause it to
+;; wrap into the footnote section tag
+;; + Current solution adds a second newline after the section tag, so it is
+;; clearly a separate paragraph. There may be stylistic objections to this.
+;; + Footnotes with multiple paragraphs should not have their first
+;; line out-dented.
+;; + Upon leaving footnote area, perform an auto-fill on an entire
+;; footnote (including multiple paragraphs), or on entire footnote area.
+;; + fill-paragraph takes arg REGION, but seemingly only when called
+;; interactively.
+;; + At some point, it became necessary to change `footnote-section-tag-regexp'
+;; to remove its trailing space. (Adaptive fill side-effect?)
+;; + useful for lazy testing
+;; (setq footnote-narrow-to-footnotes-when-editing t)
+;; (setq footnote-section-tag "Footnotes: ")
+;; (setq footnote-section-tag-regexp "Footnotes\\(\\[.\\]\\)?:")
;;; Code:
@@ -45,115 +73,113 @@
(defcustom footnote-mode-line-string " FN"
"String to display in modes section of the mode-line."
- :type 'string
- :group 'footnote)
-
-(defcustom footnote-mode-hook nil
- "Hook functions run when footnote-mode is activated."
- :type 'hook
- :group 'footnote)
+ :type 'string)
(defcustom footnote-narrow-to-footnotes-when-editing nil
"If non-nil, narrow to footnote text body while editing a footnote."
- :type 'boolean
- :group 'footnote)
+ :type 'boolean)
(defcustom footnote-prompt-before-deletion t
"If non-nil, prompt before deleting a footnote.
There is currently no way to undo deletions."
- :type 'boolean
- :group 'footnote)
+ :type 'boolean)
(defcustom footnote-spaced-footnotes t
"If non-nil, insert an empty line between footnotes.
Customizing this variable has no effect on buffers already
displaying footnotes."
- :type 'boolean
- :group 'footnote)
+ :type 'boolean)
(defcustom footnote-use-message-mode t ; Nowhere used.
"If non-nil, assume Footnoting will be done in `message-mode'."
- :type 'boolean
- :group 'footnote)
+ :type 'boolean)
(defcustom footnote-body-tag-spacing 2
"Number of spaces separating a footnote body tag and its text.
Customizing this variable has no effect on buffers already
displaying footnotes."
- :type 'integer
- :group 'footnote)
+ :type 'integer)
(defcustom footnote-prefix [(control ?c) ?!]
- "Prefix key to use for Footnote command in Footnote minor mode.
+ "Prefix key to use for Footnote commands in Footnote minor mode.
The value of this variable is checked as part of loading Footnote mode.
After that, changing the prefix key requires manipulating keymaps."
- :type 'key-sequence
- :group 'footnote)
+ :type 'key-sequence)
;;; Interface variables that probably shouldn't be changed
-(defcustom footnote-section-tag "Footnotes: "
+(defcustom footnote-section-tag "Footnotes:"
"Tag inserted at beginning of footnote section.
If you set this to the empty string, no tag is inserted and the
value of `footnote-section-tag-regexp' is ignored. Customizing
this variable has no effect on buffers already displaying
footnotes."
- :type 'string
- :group 'footnote)
+ :version "27.1"
+ :type 'string)
-(defcustom footnote-section-tag-regexp "Footnotes\\(\\[.\\]\\)?: "
+(defcustom footnote-section-tag-regexp
+ ;; Even if `footnote-section-tag' has a trailing space, let's not require it
+ ;; here, since it might be trimmed by various commands.
+ "Footnotes\\(\\[.\\]\\)?:"
"Regexp which indicates the start of a footnote section.
This variable is disregarded when `footnote-section-tag' is the
empty string. Customizing this variable has no effect on buffers
already displaying footnotes."
- :type 'regexp
- :group 'footnote)
+ :version "27.1"
+ :type 'regexp)
;; The following three should be consumed by footnote styles.
(defcustom footnote-start-tag "["
"String used to denote start of numbered footnote.
Should not be set to the empty string. Customizing this variable
has no effect on buffers already displaying footnotes."
- :type 'string
- :group 'footnote)
+ :type 'string)
(defcustom footnote-end-tag "]"
"String used to denote end of numbered footnote.
Should not be set to the empty string. Customizing this variable
has no effect on buffers already displaying footnotes."
- :type 'string
- :group 'footnote)
+ :type 'string)
-(defcustom footnote-signature-separator (if (boundp 'message-signature-separator)
- message-signature-separator
- "^-- $")
+(defcustom footnote-signature-separator
+ (if (boundp 'message-signature-separator)
+ message-signature-separator
+ "^-- $")
"Regexp used by Footnote mode to recognize signatures."
- :type 'regexp
- :group 'footnote)
+ :type 'regexp)
-;;; Private variables
+(defcustom footnote-align-to-fn-text t
+ "How to left-align footnote text.
+If nil, footnote text is to be aligned flush left with left side
+of the footnote number. If non-nil, footnote text is to be aligned
+left with the first character of footnote text."
+ :type 'boolean)
-(defvar footnote-style-number nil
- "Footnote style represented as an index into footnote-style-alist.")
-(make-variable-buffer-local 'footnote-style-number)
+;;; Private variables
-(defvar footnote-text-marker-alist nil
- "List of markers pointing to text of footnotes in message buffer.")
-(make-variable-buffer-local 'footnote-text-marker-alist)
+(defvar-local footnote-style-number nil
+ "Footnote style represented as an index into `footnote-style-alist'.")
-(defvar footnote-pointer-marker-alist nil
- "List of markers pointing to footnote pointers in message buffer.")
-(make-variable-buffer-local 'footnote-pointer-marker-alist)
+(defvar-local footnote--markers-alist nil
+ "List of (FN TEXT . POINTERS).
+Where FN is the footnote number, TEXT is a marker pointing to
+the footnote's text, and POINTERS is a list of markers pointing
+to the places from which the footnote is referenced.
+Both TEXT and POINTERS points right *before* the [...]")
(defvar footnote-mouse-highlight 'highlight
+ ;; FIXME: This `highlight' property is not currently used.
+ ;; We should use `mouse-face' and make mouse clicks work on them.
"Text property name to enable mouse over highlight.")
+(defvar footnote-mode)
+
;;; Default styles
;;; NUMERIC
(defconst footnote-numeric-regexp "[0-9]+"
"Regexp for digits.")
-(defun Footnote-numeric (n)
+(defun footnote--numeric (n)
"Numeric footnote style.
Use Arabic numerals for footnoting."
(int-to-string n))
@@ -165,7 +191,7 @@ Use Arabic numerals for footnoting."
(defconst footnote-english-upper-regexp "[A-Z]+"
"Regexp for upper case English alphabet.")
-(defun Footnote-english-upper (n)
+(defun footnote--english-upper (n)
"Upper case English footnoting.
Wrapping around the alphabet implies successive repetitions of letters."
(let* ((ltr (mod (1- n) (length footnote-english-upper)))
@@ -184,7 +210,7 @@ Wrapping around the alphabet implies successive repetitions of letters."
(defconst footnote-english-lower-regexp "[a-z]+"
"Regexp of lower case English alphabet.")
-(defun Footnote-english-lower (n)
+(defun footnote--english-lower (n)
"Lower case English footnoting.
Wrapping around the alphabet implies successive repetitions of letters."
(let* ((ltr (mod (1- n) (length footnote-english-lower)))
@@ -202,27 +228,28 @@ Wrapping around the alphabet implies successive repetitions of letters."
(50 . "l") (100 . "c") (500 . "d") (1000 . "m"))
"List of roman numerals with their values.")
-(defconst footnote-roman-lower-regexp "[ivxlcdm]+"
+(defconst footnote-roman-lower-regexp
+ (concat "[" (mapconcat #'cdr footnote-roman-lower-list "") "]+")
"Regexp of roman numerals.")
-(defun Footnote-roman-lower (n)
+(defun footnote--roman-lower (n)
"Generic Roman number footnoting."
- (Footnote-roman-common n footnote-roman-lower-list))
+ (footnote--roman-common n footnote-roman-lower-list))
;;; ROMAN UPPER
(defconst footnote-roman-upper-list
- '((1 . "I") (5 . "V") (10 . "X")
- (50 . "L") (100 . "C") (500 . "D") (1000 . "M"))
+ (mapcar (lambda (x) (cons (car x) (upcase (cdr x))))
+ footnote-roman-lower-list)
"List of roman numerals with their values.")
-(defconst footnote-roman-upper-regexp "[IVXLCDM]+"
+(defconst footnote-roman-upper-regexp (upcase footnote-roman-lower-regexp)
"Regexp of roman numerals. Not complete")
-(defun Footnote-roman-upper (n)
+(defun footnote--roman-upper (n)
"Generic Roman number footnoting."
- (Footnote-roman-common n footnote-roman-upper-list))
+ (footnote--roman-common n footnote-roman-upper-list))
-(defun Footnote-roman-common (n footnote-roman-list)
+(defun footnote--roman-common (n footnote-roman-list)
"Lower case Roman footnoting."
(let* ((our-list footnote-roman-list)
(rom-lngth (length our-list))
@@ -257,22 +284,22 @@ Wrapping around the alphabet implies successive repetitions of letters."
;; (message "pairs are: rom-low: %S, rom-high: %S, rom-div: %S"
;; rom-low-pair rom-high-pair rom-div-pair)
(cond
- ((< n 0) (error "Footnote-roman-common called with n < 0"))
+ ((< n 0) (error "footnote--roman-common called with n < 0"))
((= n 0) "")
((= n (car rom-low-pair)) (cdr rom-low-pair))
((= n (car rom-high-pair)) (cdr rom-high-pair))
((= (car rom-low-pair) (car rom-high-pair))
(concat (cdr rom-low-pair)
- (Footnote-roman-common
+ (footnote--roman-common
(- n (car rom-low-pair))
footnote-roman-list)))
((>= rom-div 0) (concat (cdr rom-div-pair) (cdr rom-high-pair)
- (Footnote-roman-common
+ (footnote--roman-common
(- n (- (car rom-high-pair)
(car rom-div-pair)))
footnote-roman-list)))
(t (concat (cdr rom-low-pair)
- (Footnote-roman-common
+ (footnote--roman-common
(- n (car rom-low-pair))
footnote-roman-list)))))))
@@ -285,7 +312,7 @@ Wrapping around the alphabet implies successive repetitions of letters."
(defconst footnote-latin-regexp (concat "[" footnote-latin-string "]")
"Regexp for Latin-1 footnoting characters.")
-(defun Footnote-latin (n)
+(defun footnote--latin (n)
"Latin-1 footnote style.
Use a range of Latin-1 non-ASCII characters for footnoting."
(string (aref footnote-latin-string
@@ -299,7 +326,7 @@ Use a range of Latin-1 non-ASCII characters for footnoting."
(defconst footnote-unicode-regexp (concat "[" footnote-unicode-string "]+")
"Regexp for Unicode footnoting characters.")
-(defun Footnote-unicode (n)
+(defun footnote--unicode (n)
"Unicode footnote style.
Use Unicode characters for footnoting."
(let (modulus result done)
@@ -310,18 +337,72 @@ Use Unicode characters for footnoting."
(push (aref footnote-unicode-string modulus) result))
(apply #'string result)))
+;; Hebrew
+
+(defconst footnote-hebrew-numeric
+ '(
+ ("א" "ב" "ג" "ד" "ה" "ו" "ז" "ח" "ט")
+ ("י" "כ" "ל" "מ" "נ" "ס" "ע" "פ" "צ")
+ ("ק" "ר" "ש" "ת" "תק" "תר" "תש" "תת" "תתק")))
+
+(defconst footnote-hebrew-numeric-regex
+ (let ((numchars (string-to-list
+ (apply #'concat (apply #'append footnote-hebrew-numeric)))))
+ (rx-to-string `(1+ (in ?' ,@numchars)))))
+;; (defconst footnote-hebrew-numeric-regex "\\([אבגדהוזחט]'\\)?\\(ת\\)?\\(ת\\)?\\([קרשת]\\)?\\([טיכלמנסעפצ]\\)?\\([אבגדהוזחט]\\)?")
+
+(defun footnote--hebrew-numeric (n)
+ "Supports 9999 footnotes, then rolls over."
+ (let* ((n (+ (mod n 10000) (/ n 10000)))
+ (thousands (/ n 1000))
+ (hundreds (/ (mod n 1000) 100))
+ (tens (/ (mod n 100) 10))
+ (units (mod n 10))
+ (special (cond
+ ((not (= tens 1)) nil)
+ ((= units 5) "טו")
+ ((= units 6) "טז"))))
+ (concat
+ (when (/= 0 thousands)
+ (concat (nth (1- thousands) (nth 0 footnote-hebrew-numeric)) "'"))
+ (when (/= 0 hundreds)
+ (nth (1- hundreds) (nth 2 footnote-hebrew-numeric)))
+ (or special
+ (concat
+ (when (/= 0 tens) (nth (1- tens) (nth 1 footnote-hebrew-numeric)))
+ (when (/= 0 units) (nth (1- units) (nth 0 footnote-hebrew-numeric))))))))
+
+(defconst footnote-hebrew-symbolic
+ '(
+ "א" "ב" "ג" "ד" "ה" "ו" "ז" "ח" "ט" "י" "כ" "ל" "מ" "נ" "ס" "ע" "פ" "צ" "ק" "ר" "ש" "ת"))
+
+(defconst footnote-hebrew-symbolic-regex
+ (concat "[" (apply #'concat footnote-hebrew-symbolic) "]"))
+
+(defun footnote--hebrew-symbolic (n)
+ "Only 22 elements, per the style of eg. 'פירוש שפתי חכמים על רש״י'.
+Proceeds from `י' to `כ', from `צ' to `ק'. After `ת', rolls over to `א'."
+ (nth (mod (1- n) 22) footnote-hebrew-symbolic))
+
;;; list of all footnote styles
(defvar footnote-style-alist
- `((numeric Footnote-numeric ,footnote-numeric-regexp)
- (english-lower Footnote-english-lower ,footnote-english-lower-regexp)
- (english-upper Footnote-english-upper ,footnote-english-upper-regexp)
- (roman-lower Footnote-roman-lower ,footnote-roman-lower-regexp)
- (roman-upper Footnote-roman-upper ,footnote-roman-upper-regexp)
- (latin Footnote-latin ,footnote-latin-regexp)
- (unicode Footnote-unicode ,footnote-unicode-regexp))
+ `((numeric footnote--numeric ,footnote-numeric-regexp)
+ (english-lower footnote--english-lower ,footnote-english-lower-regexp)
+ (english-upper footnote--english-upper ,footnote-english-upper-regexp)
+ (roman-lower footnote--roman-lower ,footnote-roman-lower-regexp)
+ (roman-upper footnote--roman-upper ,footnote-roman-upper-regexp)
+ (latin footnote--latin ,footnote-latin-regexp)
+ (unicode footnote--unicode ,footnote-unicode-regexp)
+ (hebrew-numeric footnote--hebrew-numeric ,footnote-hebrew-numeric-regex)
+ (hebrew-symbolic footnote--hebrew-symbolic ,footnote-hebrew-symbolic-regex))
"Styles of footnote tags available.
-By default only boring Arabic numbers, English letters and Roman Numerals
-are available.")
+By default, Arabic numbers, English letters, Roman Numerals,
+Latin and Unicode superscript characters, and Hebrew numerals
+are available.
+Each element of the list should be of the form (NAME FUNCTION REGEXP)
+where NAME is a symbol, FUNCTION takes a footnote number and
+returns the corresponding representation in that style as a string,
+and REGEXP should be a regexp that matches any output of FUNCTION.")
(defcustom footnote-style 'numeric
"Default style used for footnoting.
@@ -332,6 +413,8 @@ roman-lower == i, ii, iii, iv, v, ...
roman-upper == I, II, III, IV, V, ...
latin == ¹ ² ³ º ª § ¶
unicode == ¹, ², ³, ...
+hebrew-numeric == א, ב, ..., יא, ..., תקא...
+hebrew-symbolic == א, ב, ..., י, כ, ..., צ, ק, ..., ת, א
See also variables `footnote-start-tag' and `footnote-end-tag'.
Note: some characters in the unicode style may not show up
@@ -339,373 +422,355 @@ properly if the default font does not contain those characters.
Customizing this variable has no effect on buffers already
displaying footnotes. To change the style of footnotes in such a
-buffer use the command `Footnote-set-style'."
+buffer use the command `footnote-set-style'."
:type (cons 'choice (mapcar (lambda (x) (list 'const (car x)))
- footnote-style-alist))
- :group 'footnote)
+ footnote-style-alist)))
;;; Style utilities & functions
-(defun Footnote-style-p (style)
- "Return non-nil if style is a valid style known to `footnote-mode'."
- (assq style footnote-style-alist))
-(defun Footnote-index-to-string (index)
+(defun footnote--index-to-string (index)
"Convert a binary index into a string to display as a footnote.
Conversion is done based upon the current selected style."
- (let ((alist (if (Footnote-style-p footnote-style)
- (assq footnote-style footnote-style-alist)
- (nth 0 footnote-style-alist))))
+ (let ((alist (or (assq footnote-style footnote-style-alist)
+ (nth 0 footnote-style-alist))))
(funcall (nth 1 alist) index)))
-(defun Footnote-current-regexp ()
+(defun footnote--current-regexp (&optional index-regexp)
"Return the regexp of the index of the current style."
- (concat (nth 2 (or (assq footnote-style footnote-style-alist)
- (nth 0 footnote-style-alist)))
- "*"))
-
-(defun Footnote-refresh-footnotes (&optional index-regexp)
+ (let ((regexp (or index-regexp
+ (nth 2 (or (assq footnote-style footnote-style-alist)
+ (nth 0 footnote-style-alist))))))
+ (concat
+ (regexp-quote footnote-start-tag) "\\("
+ ;; Hack to avoid repetition of repetition.
+ ;; FIXME: I'm not sure the added * makes sense at all; there is
+ ;; always a single number within the footnote-{start,end}-tag pairs.
+ (if (string-match "[^\\]\\\\\\{2\\}*[*+?]\\'" regexp)
+ (substring regexp 0 -1)
+ regexp)
+ "*\\)" (regexp-quote footnote-end-tag))))
+
+(defun footnote--refresh-footnotes (&optional index-regexp)
"Redraw all footnotes.
-You must call this or arrange to have this called after changing footnote
-styles."
- (unless index-regexp
- (setq index-regexp (Footnote-current-regexp)))
- (save-excursion
- ;; Take care of the pointers first
- (let ((i 0) locn alist)
- (while (setq alist (nth i footnote-pointer-marker-alist))
- (setq locn (cdr alist))
- (while locn
- (goto-char (car locn))
+You must call this or arrange to have this called after changing
+footnote styles."
+ (let ((fn-regexp (footnote--current-regexp index-regexp)))
+ (save-excursion
+ (pcase-dolist (`(,fn ,text . ,pointers) footnote--markers-alist)
+ ;; Take care of the pointers first.
+ (dolist (locn pointers)
+ (goto-char locn)
;; Try to handle the case where `footnote-start-tag' and
;; `footnote-end-tag' are the same string.
- (when (looking-back (concat
- (regexp-quote footnote-start-tag)
- "\\(" index-regexp "+\\)"
- (regexp-quote footnote-end-tag))
- (line-beginning-position))
+ (when (looking-at fn-regexp)
(replace-match
(propertize
(concat
footnote-start-tag
- (Footnote-index-to-string (1+ i))
+ (footnote--index-to-string fn)
footnote-end-tag)
- 'footnote-number (1+ i) footnote-mouse-highlight t)
- nil "\\1"))
- (setq locn (cdr locn)))
- (setq i (1+ i))))
-
- ;; Now take care of the text section
- (let ((i 0) alist)
- (while (setq alist (nth i footnote-text-marker-alist))
- (goto-char (cdr alist))
- (when (looking-at (concat
- (regexp-quote footnote-start-tag)
- "\\(" index-regexp "+\\)"
- (regexp-quote footnote-end-tag)))
+ 'footnote-number fn footnote-mouse-highlight t)
+ t t)))
+
+ ;; Now take care of the text section
+ (goto-char text)
+ (when (looking-at fn-regexp)
(replace-match
(propertize
(concat
footnote-start-tag
- (Footnote-index-to-string (1+ i))
+ (footnote--index-to-string fn)
footnote-end-tag)
- 'footnote-number (1+ i))
- nil "\\1"))
- (setq i (1+ i))))))
-
-(defun Footnote-assoc-index (key alist)
- "Give index of key in alist."
- (let ((i 0) (max (length alist)) rc)
- (while (and (null rc)
- (< i max))
- (when (eq key (car (nth i alist)))
- (setq rc i))
- (setq i (1+ i)))
- rc))
+ 'footnote-number fn)
+ t t))))))
-(defun Footnote-cycle-style ()
+(defun footnote-cycle-style ()
"Select next defined footnote style."
(interactive)
- (let ((old (Footnote-assoc-index footnote-style footnote-style-alist))
- (max (length footnote-style-alist))
- idx)
- (setq idx (1+ old))
- (when (>= idx max)
- (setq idx 0))
- (setq footnote-style (car (nth idx footnote-style-alist)))
- (Footnote-refresh-footnotes (nth 2 (nth old footnote-style-alist)))))
-
-(defun Footnote-set-style (&optional style)
+ (let ((old-desc (assq footnote-style footnote-style-alist)))
+ (setq footnote-style (caar (or (cdr (memq old-desc footnote-style-alist))
+ footnote-style-alist)))
+ (footnote--refresh-footnotes (nth 2 old-desc))
+ (message "Style set to %s" footnote-style)))
+
+(defun footnote-set-style (style)
"Select a specific style."
(interactive
(list (intern (completing-read
"Footnote Style: "
- obarray #'Footnote-style-p 'require-match))))
- (let ((old (Footnote-assoc-index footnote-style footnote-style-alist)))
+ footnote-style-alist nil 'require-match))))
+ (let ((old-desc (assq footnote-style footnote-style-alist)))
(setq footnote-style style)
- (Footnote-refresh-footnotes (nth 2 (nth old footnote-style-alist)))))
+ (footnote--refresh-footnotes (nth 2 old-desc))))
;; Internal functions
-(defun Footnote-insert-numbered-footnote (arg &optional mousable)
- "Insert numbered footnote at (point)."
+(defun footnote--insert-numbered-footnote (arg &optional mousable)
+ "Insert numbered footnote at point.
+Return a marker pointing to the beginning of the [...]."
(let ((string (concat footnote-start-tag
- (Footnote-index-to-string arg)
- footnote-end-tag)))
- (insert-before-markers
+ (footnote--index-to-string arg)
+ footnote-end-tag))
+ (pos (point)))
+ (insert
(if mousable
(propertize
string 'footnote-number arg footnote-mouse-highlight t)
- (propertize string 'footnote-number arg)))))
+ (propertize string 'footnote-number arg)))
+ (copy-marker pos t)))
-(defun Footnote-renumber (from to pointer-alist text-alist)
+(defun footnote--renumber (to alist-elem)
"Renumber a single footnote."
- (let* ((posn-list (cdr pointer-alist)))
- (setcar pointer-alist to)
- (setcar text-alist to)
- (while posn-list
- (goto-char (car posn-list))
- (when (looking-back (concat (regexp-quote footnote-start-tag)
- (Footnote-current-regexp)
- (regexp-quote footnote-end-tag))
- (line-beginning-position))
- (replace-match
- (propertize
+ (unless (equal to (car alist-elem)) ;Nothing to do.
+ (let* ((fn-regexp (footnote--current-regexp)))
+ (setcar alist-elem to)
+ (dolist (posn (cddr alist-elem))
+ (goto-char posn)
+ (when (looking-at fn-regexp)
+ (replace-match
+ (propertize
+ (concat footnote-start-tag
+ (footnote--index-to-string to)
+ footnote-end-tag)
+ 'footnote-number to footnote-mouse-highlight t))))
+ (goto-char (cadr alist-elem))
+ (when (looking-at fn-regexp)
+ (replace-match
+ (propertize
(concat footnote-start-tag
- (Footnote-index-to-string to)
+ (footnote--index-to-string to)
footnote-end-tag)
- 'footnote-number to footnote-mouse-highlight t)))
- (setq posn-list (cdr posn-list)))
- (goto-char (cdr text-alist))
- (when (looking-at (concat (regexp-quote footnote-start-tag)
- (Footnote-current-regexp)
- (regexp-quote footnote-end-tag)))
- (replace-match
- (propertize
- (concat footnote-start-tag
- (Footnote-index-to-string to)
- footnote-end-tag)
- 'footnote-number to)))))
-
-;; Not needed?
-(defun Footnote-narrow-to-footnotes ()
+ 'footnote-number to))))))
+
+(defun footnote--narrow-to-footnotes ()
"Restrict text in buffer to show only text of footnotes."
- (interactive) ; testing
- (goto-char (point-max))
- (when (re-search-backward footnote-signature-separator nil t)
- (let ((end (point)))
- (cond
- ((and (not (string-equal footnote-section-tag ""))
- (re-search-backward
- (concat "^" footnote-section-tag-regexp) nil t))
- (narrow-to-region (point) end))
- (footnote-text-marker-alist
- (narrow-to-region (cdar footnote-text-marker-alist) end))))))
-
-(defun Footnote-goto-char-point-max ()
+ (interactive) ; testing
+ (narrow-to-region (footnote--get-area-point-min)
+ (footnote--get-area-point-max)))
+
+(defun footnote--goto-char-point-max ()
"Move to end of buffer or prior to start of .signature."
(goto-char (point-max))
(or (re-search-backward footnote-signature-separator nil t)
(point)))
-(defun Footnote-insert-text-marker (arg locn)
- "Insert a marker pointing to footnote ARG, at buffer location LOCN."
- (let ((marker (make-marker)))
- (unless (assq arg footnote-text-marker-alist)
- (set-marker marker locn)
- (setq footnote-text-marker-alist
- (cons (cons arg marker) footnote-text-marker-alist))
- (setq footnote-text-marker-alist
- (Footnote-sort footnote-text-marker-alist)))))
-
-(defun Footnote-insert-pointer-marker (arg locn)
- "Insert a marker pointing to footnote ARG, at buffer location LOCN."
- (let ((marker (make-marker))
- alist)
- (set-marker marker locn)
- (if (setq alist (assq arg footnote-pointer-marker-alist))
- (setf alist
- (cons marker (cdr alist)))
- (setq footnote-pointer-marker-alist
- (cons (cons arg (list marker)) footnote-pointer-marker-alist))
- (setq footnote-pointer-marker-alist
- (Footnote-sort footnote-pointer-marker-alist)))))
-
-(defun Footnote-insert-footnote (arg)
+(defun footnote--insert-markers (arg text ptr)
+ "Insert the markers of new footnote ARG."
+ (cl-assert (and (numberp arg) (markerp text) (markerp ptr)))
+ (cl-assert (not (assq arg footnote--markers-alist)))
+ (push `(,arg ,text ,ptr) footnote--markers-alist)
+ (setq footnote--markers-alist
+ (footnote--sort footnote--markers-alist)))
+
+(defun footnote--goto-first ()
+ "Go to beginning of footnote area and return non-nil if successful.
+Presumes we're within the footnote area already."
+ (cond
+ ((not (string-equal footnote-section-tag ""))
+ (re-search-backward
+ (concat "^" footnote-section-tag-regexp) nil t))
+ (footnote--markers-alist
+ (goto-char (cadr (car footnote--markers-alist))))))
+
+(defun footnote--insert-footnote (arg)
"Insert a footnote numbered ARG, at (point)."
(push-mark)
- (Footnote-insert-pointer-marker arg (point))
- (Footnote-insert-numbered-footnote arg t)
- (Footnote-goto-char-point-max)
- (if (cond
- ((not (string-equal footnote-section-tag ""))
- (re-search-backward (concat "^" footnote-section-tag-regexp) nil t))
- (footnote-text-marker-alist
- (goto-char (cdar footnote-text-marker-alist))))
- (save-restriction
- (when footnote-narrow-to-footnotes-when-editing
- (Footnote-narrow-to-footnotes))
- (Footnote-goto-footnote (1- arg)) ; evil, FIXME (less evil now)
- ;; (message "Inserting footnote %d" arg)
- (unless
- (or (eq arg 1)
- (when (re-search-forward
- (if footnote-spaced-footnotes
- "\n\n"
- (concat "\n"
- (regexp-quote footnote-start-tag)
- (Footnote-current-regexp)
- (regexp-quote footnote-end-tag)))
- nil t)
- (unless (beginning-of-line) t))
- (Footnote-goto-char-point-max)
- (cond
- ((not (string-equal footnote-section-tag ""))
- (re-search-backward
- (concat "^" footnote-section-tag-regexp) nil t))
- (footnote-text-marker-alist
- (goto-char (cdar footnote-text-marker-alist)))))))
- (unless (looking-at "^$")
- (insert "\n"))
- (when (eobp)
- (insert "\n"))
- (unless (string-equal footnote-section-tag "")
- (insert footnote-section-tag "\n")))
- (let ((old-point (point)))
- (Footnote-insert-numbered-footnote arg nil)
- (Footnote-insert-text-marker arg old-point)))
-
-(defun Footnote-sort (list)
- (sort list (lambda (e1 e2)
- (< (car e1) (car e2)))))
-
-(defun Footnote-text-under-cursor ()
- "Return the number of footnote if in footnote text.
+ (let ((ptr (footnote--insert-numbered-footnote arg t)))
+ (footnote--goto-char-point-max)
+ (if (footnote--goto-first)
+ (save-restriction
+ (when footnote-narrow-to-footnotes-when-editing
+ (footnote--narrow-to-footnotes))
+ (footnote-goto-footnote (1- arg)) ; evil, FIXME (less evil now)
+ ;; (message "Inserting footnote %d" arg)
+ (or (eq arg 1)
+ (when (re-search-forward
+ (if footnote-spaced-footnotes
+ "\n\n"
+ (concat "\n" (footnote--current-regexp)))
+ nil t)
+ (beginning-of-line)
+ t)
+ (footnote--goto-char-point-max)
+ (footnote--goto-first)))
+ (unless (looking-at "^$")
+ (insert "\n"))
+ (when (eobp)
+ (insert "\n"))
+ (unless (string-equal footnote-section-tag "")
+ (insert footnote-section-tag "\n")))
+ (let ((text (footnote--insert-numbered-footnote arg nil)))
+ (footnote--insert-markers arg text ptr))))
+
+(defun footnote--sort (list)
+ (sort list #'car-less-than-car))
+
+(defun footnote--text-under-cursor ()
+ "Return the number of the current footnote if in footnote text.
Return nil if the cursor is not positioned over the text of
a footnote."
- (when (and (let ((old-point (point)))
- (save-excursion
- (save-restriction
- (Footnote-narrow-to-footnotes)
- (and (>= old-point (point-min))
- (<= old-point (point-max))))))
- footnote-text-marker-alist
- (>= (point) (cdar footnote-text-marker-alist)))
- (let ((i 1)
- alist-txt rc)
- (while (and (setq alist-txt (nth i footnote-text-marker-alist))
- (null rc))
- (when (< (point) (cdr alist-txt))
- (setq rc (car (nth (1- i) footnote-text-marker-alist))))
- (setq i (1+ i)))
- (when (and (null rc)
- (null alist-txt))
- (setq rc (car (nth (1- i) footnote-text-marker-alist))))
- rc)))
-
-(defun Footnote-under-cursor ()
+ (when (<= (point) (footnote--get-area-point-max))
+ (let ((result nil))
+ (pcase-dolist (`(,fn ,text . ,_) footnote--markers-alist)
+ (if (<= text (point))
+ (setq result fn)))
+ result)))
+
+(defun footnote--under-cursor ()
"Return the number of the footnote underneath the cursor.
Return nil if the cursor is not over a footnote."
(or (get-text-property (point) 'footnote-number)
- (Footnote-text-under-cursor)))
+ (footnote--text-under-cursor)))
+
+(defun footnote--calc-fn-alignment-column ()
+ "Calculate the left alignment for footnote text."
+ ;; FIXME: Maybe it would be better to go to the footnote's beginning and
+ ;; see at which column it starts.
+ (+ footnote-body-tag-spacing
+ (string-width
+ (concat footnote-start-tag footnote-end-tag
+ (footnote--index-to-string
+ (caar (last footnote--markers-alist)))))))
+
+(defun footnote--fill-prefix-string ()
+ "Return the fill prefix to be used by footnote mode."
+ ;; TODO: Prefix to this value other prefix strings, such as those
+ ;; designating a comment line, a message response, or a boxquote.
+ (make-string (footnote--calc-fn-alignment-column) ?\s))
+
+(defun footnote--point-in-body-p ()
+ "Return non-nil if point is in the buffer text area,
+i.e. before the beginning of the footnote area."
+ (< (point) (footnote--get-area-point-min)))
+
+(defun footnote--get-area-point-min (&optional before-tag)
+ "Return start of the first footnote.
+If there is no footnote area, returns `point-max'.
+With optional arg BEFORE-TAG, return position of the `footnote-section-tag'
+instead, if applicable."
+ (cond
+ ;; FIXME: Shouldn't we use `footnote--get-area-point-max' instead?
+ ((not footnote--markers-alist) (point-max))
+ ((not before-tag) (cadr (car footnote--markers-alist)))
+ ((string-equal footnote-section-tag "") (cadr (car footnote--markers-alist)))
+ (t
+ (save-excursion
+ (goto-char (cadr (car footnote--markers-alist)))
+ (if (re-search-backward (concat "^" footnote-section-tag-regexp) nil t)
+ (point)
+ (message "Footnote section tag not found!")
+ ;; This `else' should never happen, and indicates an error,
+ ;; ie. footnotes already exist and a footnote-section-tag is defined,
+ ;; but the section tag hasn't been found. We choose to assume that the
+ ;; user deleted it intentionally and wants us to behave in this buffer
+ ;; as if the section tag was set "", so we do that, now.
+ ;;(setq footnote-section-tag "")
+ ;;
+ ;; HOWEVER: The rest of footnote mode does not currently honor or
+ ;; account for this.
+ ;;
+ ;; To illustrate the difference in behavior, create a few footnotes,
+ ;; delete the section tag, and create another footnote. Then undo,
+ ;; comment the above line (that sets the tag to ""), re-evaluate this
+ ;; function, and repeat.
+ ;;
+ ;; TODO: integrate sanity checks at reasonable operational points.
+ (point))))))
+
+(defun footnote--get-area-point-max ()
+ "Return the end of footnote area.
+This is either `point-max' or the start of a `.signature' string, as
+defined by variable `footnote-signature-separator'. If there is no
+footnote area, returns `point-max'."
+ (save-excursion (footnote--goto-char-point-max)))
+
+(defun footnote--adaptive-fill-function (orig-fun)
+ (or
+ (and
+ footnote-mode
+ footnote-align-to-fn-text
+ (footnote--text-under-cursor)
+ ;; (not (footnote--point-in-body-p))
+ ;; (< (point) (footnote--signature-area-start-point))
+ (footnote--fill-prefix-string))
+ ;; If not within a footnote's text, fallback to the default.
+ (funcall orig-fun)))
;;; User functions
-(defun Footnote-make-hole ()
+(defun footnote--make-hole ()
+ "Make room in the alist for a new footnote at point.
+Return the footnote number to use."
(save-excursion
- (let ((i 0)
- (notes (length footnote-pointer-marker-alist))
- alist-ptr alist-txt rc)
- (while (< i notes)
- (setq alist-ptr (nth i footnote-pointer-marker-alist))
- (setq alist-txt (nth i footnote-text-marker-alist))
- (when (< (point) (- (cadr alist-ptr) 3))
+ (let (rc)
+ (dolist (alist-elem footnote--markers-alist)
+ (when (<= (point) (cl-caddr alist-elem))
(unless rc
- (setq rc (car alist-ptr)))
+ (setq rc (car alist-elem)))
(save-excursion
(message "Renumbering from %s to %s"
- (Footnote-index-to-string (car alist-ptr))
- (Footnote-index-to-string
- (1+ (car alist-ptr))))
- (Footnote-renumber (car alist-ptr)
- (1+ (car alist-ptr))
- alist-ptr
- alist-txt)))
- (setq i (1+ i)))
- rc)))
-
-(defun Footnote-add-footnote (&optional arg)
+ (footnote--index-to-string (car alist-elem))
+ (footnote--index-to-string
+ (1+ (car alist-elem))))
+ (footnote--renumber (1+ (car alist-elem))
+ alist-elem))))
+ (or rc
+ (1+ (or (caar (last footnote--markers-alist)) 0))))))
+
+(defun footnote-add-footnote ()
"Add a numbered footnote.
The number the footnote receives is dependent upon the relative location
of any other previously existing footnotes.
If the variable `footnote-narrow-to-footnotes-when-editing' is set,
the buffer is narrowed to the footnote body. The restriction is removed
-by using `Footnote-back-to-message'."
- (interactive "*P")
- (let ((num
- (if footnote-text-marker-alist
- (if (< (point) (cl-cadar (last footnote-pointer-marker-alist)))
- (Footnote-make-hole)
- (1+ (caar (last footnote-text-marker-alist))))
- 1)))
+by using `footnote-back-to-message'."
+ (interactive "*")
+ (let ((num (footnote--make-hole)))
(message "Adding footnote %d" num)
- (Footnote-insert-footnote num)
- (insert-before-markers (make-string footnote-body-tag-spacing ? ))
- (let ((opoint (point)))
- (save-excursion
- (insert-before-markers
- (if footnote-spaced-footnotes
- "\n\n"
- "\n"))
- (when footnote-narrow-to-footnotes-when-editing
- (Footnote-narrow-to-footnotes)))
- ;; Emacs/XEmacs bug? save-excursion doesn't restore point when using
- ;; insert-before-markers.
- (goto-char opoint))))
-
-(defun Footnote-delete-footnote (&optional arg)
+ (footnote--insert-footnote num)
+ (insert (make-string footnote-body-tag-spacing ? ))
+ (save-excursion
+ (insert
+ (if footnote-spaced-footnotes
+ "\n\n"
+ "\n"))
+ (when footnote-narrow-to-footnotes-when-editing
+ (footnote--narrow-to-footnotes)))))
+
+(defun footnote-delete-footnote (&optional arg)
"Delete a numbered footnote.
With no parameter, delete the footnote under (point). With ARG specified,
delete the footnote with that number."
(interactive "*P")
(unless arg
- (setq arg (Footnote-under-cursor)))
+ (setq arg (footnote--under-cursor)))
(when (and arg
(or (not footnote-prompt-before-deletion)
(y-or-n-p (format "Really delete footnote %d?" arg))))
- (let (alist-ptr alist-txt locn)
- (setq alist-ptr (assq arg footnote-pointer-marker-alist))
- (setq alist-txt (assq arg footnote-text-marker-alist))
- (unless (and alist-ptr alist-txt)
- (error "Can't delete footnote %d" arg))
- (setq locn (cdr alist-ptr))
- (while (car locn)
+ (let ((alist-elem (or (assq arg footnote--markers-alist)
+ (error "Can't delete footnote %d" arg)))
+ (fn-regexp (footnote--current-regexp)))
+ (dolist (locn (cddr alist-elem))
(save-excursion
- (goto-char (car locn))
- (when (looking-back (concat (regexp-quote footnote-start-tag)
- (Footnote-current-regexp)
- (regexp-quote footnote-end-tag))
- (line-beginning-position))
- (delete-region (match-beginning 0) (match-end 0))))
- (setq locn (cdr locn)))
+ (goto-char locn)
+ (when (looking-at fn-regexp)
+ (delete-region (match-beginning 0) (match-end 0)))))
(save-excursion
- (goto-char (cdr alist-txt))
+ (goto-char (cadr alist-elem))
(delete-region
(point)
(if footnote-spaced-footnotes
(search-forward "\n\n" nil t)
- (save-restriction
+ (save-restriction ; <= 2017-12 Boruch: WHY?? I see no narrowing / widening here.
(end-of-line)
(next-single-char-property-change
- (point) 'footnote-number nil (Footnote-goto-char-point-max))))))
- (setq footnote-pointer-marker-alist
- (delq alist-ptr footnote-pointer-marker-alist))
- (setq footnote-text-marker-alist
- (delq alist-txt footnote-text-marker-alist))
- (Footnote-renumber-footnotes)
- (when (and (null footnote-text-marker-alist)
- (null footnote-pointer-marker-alist))
+ (point) 'footnote-number nil (footnote--goto-char-point-max))))))
+ (setq footnote--markers-alist
+ (delq alist-elem footnote--markers-alist))
+ (if footnote--markers-alist
+ (footnote-renumber-footnotes)
(save-excursion
(if (not (string-equal footnote-section-tag ""))
- (let* ((end (Footnote-goto-char-point-max))
+ (let* ((end (footnote--goto-char-point-max))
(start (1- (re-search-backward
(concat "^" footnote-section-tag-regexp)
nil t))))
@@ -715,67 +780,64 @@ delete the footnote with that number."
(delete-region start (if (< end (point-max))
end
(point-max))))
- (Footnote-goto-char-point-max)
+ (footnote--goto-char-point-max)
(when (looking-back "\n\n" (- (point) 2))
(kill-line -1))))))))
-(defun Footnote-renumber-footnotes (&optional arg)
+(defun footnote-renumber-footnotes ()
"Renumber footnotes, starting from 1."
- (interactive "*P")
+ (interactive "*")
(save-excursion
- (let ((i 0)
- (notes (length footnote-pointer-marker-alist))
- alist-ptr alist-txt)
- (while (< i notes)
- (setq alist-ptr (nth i footnote-pointer-marker-alist))
- (setq alist-txt (nth i footnote-text-marker-alist))
- (unless (= (1+ i) (car alist-ptr))
- (Footnote-renumber (car alist-ptr) (1+ i) alist-ptr alist-txt))
+ (let ((i 1))
+ (dolist (alist-elem footnote--markers-alist)
+ (footnote--renumber i alist-elem)
(setq i (1+ i))))))
-(defun Footnote-goto-footnote (&optional arg)
+(defun footnote-goto-footnote (&optional arg)
"Jump to the text of a footnote.
With no parameter, jump to the text of the footnote under (point). With ARG
specified, jump to the text of that footnote."
(interactive "P")
(unless arg
- (setq arg (Footnote-under-cursor)))
- (let ((footnote (assq arg footnote-text-marker-alist)))
+ (setq arg (footnote--under-cursor)))
+ (let ((footnote (assq arg footnote--markers-alist)))
(cond
(footnote
- (goto-char (cdr footnote)))
+ (goto-char (cadr footnote)))
((eq arg 0)
(goto-char (point-max))
(cond
((not (string-equal footnote-section-tag ""))
(re-search-backward (concat "^" footnote-section-tag-regexp))
(forward-line 1))
- (footnote-text-marker-alist
- (goto-char (cdar footnote-text-marker-alist)))))
+ (footnote--markers-alist
+ (goto-char (cadr (car footnote--markers-alist))))))
(t
(error "I don't see a footnote here")))))
-(defun Footnote-back-to-message (&optional arg)
+(defun footnote-back-to-message ()
"Move cursor back to footnote referent.
If the cursor is not over the text of a footnote, point is not changed.
If the buffer was narrowed due to `footnote-narrow-to-footnotes-when-editing'
being set it is automatically widened."
- (interactive "P")
- (let ((note (Footnote-text-under-cursor)))
+ (interactive)
+ (let ((note (footnote--text-under-cursor)))
(when note
(when footnote-narrow-to-footnotes-when-editing
(widen))
- (goto-char (cadr (assq note footnote-pointer-marker-alist))))))
+ (goto-char (cl-caddr (assq note footnote--markers-alist)))
+ (when (looking-at (footnote--current-regexp))
+ (goto-char (match-end 0))))))
(defvar footnote-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map "a" 'Footnote-add-footnote)
- (define-key map "b" 'Footnote-back-to-message)
- (define-key map "c" 'Footnote-cycle-style)
- (define-key map "d" 'Footnote-delete-footnote)
- (define-key map "g" 'Footnote-goto-footnote)
- (define-key map "r" 'Footnote-renumber-footnotes)
- (define-key map "s" 'Footnote-set-style)
+ (define-key map "a" #'footnote-add-footnote)
+ (define-key map "b" #'footnote-back-to-message)
+ (define-key map "c" #'footnote-cycle-style)
+ (define-key map "d" #'footnote-delete-footnote)
+ (define-key map "g" #'footnote-goto-footnote)
+ (define-key map "r" #'footnote-renumber-footnotes)
+ (define-key map "s" #'footnote-set-style)
map))
(defvar footnote-minor-mode-map
@@ -787,9 +849,6 @@ being set it is automatically widened."
;;;###autoload
(define-minor-mode footnote-mode
"Toggle Footnote mode.
-With a prefix argument ARG, enable Footnote mode if ARG is
-positive, and disable it otherwise. If called from Lisp, enable
-the mode if ARG is omitted or nil.
Footnote mode is a buffer-local minor mode. If enabled, it
provides footnote support for `message-mode'. To get started,
@@ -798,8 +857,14 @@ play around with the following keys:
:lighter footnote-mode-line-string
:keymap footnote-minor-mode-map
;; (filladapt-mode t)
+ (unless adaptive-fill-function
+ ;; nil and `ignore' have the same semantics for adaptive-fill-function,
+ ;; but only `ignore' behaves correctly with add/remove-function.
+ (setq adaptive-fill-function #'ignore))
+ (remove-function (local 'adaptive-fill-function)
+ #'footnote--adaptive-fill-function)
(when footnote-mode
- ;; (Footnote-setup-keybindings)
+ ;; (footnote-setup-keybindings)
(make-local-variable 'footnote-style)
(make-local-variable 'footnote-body-tag-spacing)
(make-local-variable 'footnote-spaced-footnotes)
@@ -807,7 +872,11 @@ play around with the following keys:
(make-local-variable 'footnote-section-tag-regexp)
(make-local-variable 'footnote-start-tag)
(make-local-variable 'footnote-end-tag)
+ (make-local-variable 'adaptive-fill-function)
+ (add-function :around (local 'adaptive-fill-function)
+ #'footnote--adaptive-fill-function)
+ ;; Filladapt was an XEmacs package which is now in GNU ELPA.
(when (boundp 'filladapt-token-table)
;; add tokens to filladapt to match footnotes
;; 1] xxxxxxxxxxx x x x or [1] x x x x x x x
diff --git a/lisp/mail/hashcash.el b/lisp/mail/hashcash.el
index 9fdc7ea756c..60689529974 100644
--- a/lisp/mail/hashcash.el
+++ b/lisp/mail/hashcash.el
@@ -1,4 +1,4 @@
-;;; hashcash.el --- Add hashcash payments to email
+;;; hashcash.el --- Add hashcash payments to email -*- lexical-binding:t -*-
;; Copyright (C) 2003-2005, 2007-2019 Free Software Foundation, Inc.
@@ -47,7 +47,7 @@
;;; Code:
-(eval-when-compile (require 'cl)) ; for case
+(eval-when-compile (require 'cl-lib))
(defgroup hashcash nil
"Hashcash configuration."
@@ -133,18 +133,18 @@ For example, you may want to set this to (\"-Z2\") to reduce header length."
(declare-function message-narrow-to-headers-or-head "message" ())
(declare-function message-fetch-field "message" (header &optional not-all))
-(declare-function message-goto-eoh "message" ())
+(declare-function message-goto-eoh "message" (&optional interactive))
(declare-function message-narrow-to-headers "message" ())
(defun hashcash-token-substring ()
(save-excursion
(let ((token ""))
- (loop
+ (cl-loop
(setq token
(concat token (buffer-substring (point) (hashcash-point-at-eol))))
(goto-char (hashcash-point-at-eol))
(forward-char 1)
- (unless (looking-at "[ \t]") (return token))
+ (unless (looking-at "[ \t]") (cl-return token))
(while (looking-at "[ \t]") (forward-char 1))))))
(defun hashcash-payment-required (addr)
@@ -182,8 +182,7 @@ Return immediately. Call CALLBACK with process and result when ready."
(setq hashcash-process-alist (cons
(cons process (current-buffer))
hashcash-process-alist))
- (set-process-filter process `(lambda (process output)
- (funcall ,callback process output))))
+ (set-process-filter process callback))
(funcall callback nil nil)))
(defun hashcash-check-payment (token str val)
@@ -244,8 +243,9 @@ Only start calculation. Results are inserted when ready."
(hashcash-generate-payment-async
(hashcash-payment-to arg)
(hashcash-payment-required arg)
- `(lambda (process payment)
- (hashcash-insert-payment-async-2 ,(current-buffer) process payment)))))
+ (let ((buf (current-buffer)))
+ (lambda (process payment)
+ (hashcash-insert-payment-async-2 buf process payment))))))
(defun hashcash-insert-payment-async-2 (buffer process pay)
(when (buffer-live-p buffer)
@@ -298,7 +298,7 @@ BUFFER defaults to the current buffer."
(let* ((split (split-string token ":"))
(key (if (< (hashcash-version token) 1.2)
(nth 1 split)
- (case (string-to-number (nth 0 split))
+ (pcase (string-to-number (nth 0 split))
(0 (nth 2 split))
(1 (nth 3 split))))))
(cond ((null resource)
diff --git a/lisp/mail/ietf-drums.el b/lisp/mail/ietf-drums.el
index bc0fc2b74e6..29752cb5c28 100644
--- a/lisp/mail/ietf-drums.el
+++ b/lisp/mail/ietf-drums.el
@@ -1,4 +1,4 @@
-;;; ietf-drums.el --- Functions for parsing RFC 2822 headers
+;;; ietf-drums.el --- Functions for parsing RFC 2822 headers -*- lexical-binding:t -*-
;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
@@ -37,7 +37,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(defvar ietf-drums-no-ws-ctl-token "\001-\010\013\014\016-\037\177"
"US-ASCII control characters excluding CR, LF and white space.")
@@ -78,10 +78,10 @@ backslash and doublequote.")
(defun ietf-drums-token-to-list (token)
"Translate TOKEN into a list of characters."
(let ((i 0)
- b e c out range)
+ b c out range)
(while (< i (length token))
(setq c (aref token i))
- (incf i)
+ (cl-incf i)
(cond
((eq c ?-)
(if b
@@ -90,7 +90,7 @@ backslash and doublequote.")
(range
(while (<= b c)
(push (make-char 'ascii b) out)
- (incf b))
+ (cl-incf b))
(setq range nil))
((= i (length token))
(push (make-char 'ascii c) out))
@@ -115,7 +115,7 @@ backslash and doublequote.")
(setq c (char-after))
(cond
((eq c ?\")
- (condition-case err
+ (condition-case nil
(forward-sexp 1)
(error (goto-char (point-max)))))
((eq c ?\()
@@ -185,8 +185,12 @@ STRING is assumed to be a string that is extracted from
the Content-Transfer-Encoding header of a mail."
(ietf-drums-remove-garbage (inline (ietf-drums-strip string))))
-(defun ietf-drums-parse-address (string)
- "Parse STRING and return a MAILBOX / DISPLAY-NAME pair."
+(declare-function rfc2047-decode-string "rfc2047" (string &optional address-mime))
+
+(defun ietf-drums-parse-address (string &optional decode)
+ "Parse STRING and return a MAILBOX / DISPLAY-NAME pair.
+If DECODE, the DISPLAY-NAME will have RFC2047 decoding performed
+(that's the \"=?utf...q...=?\") stuff."
(with-temp-buffer
(let (display-name mailbox c display-string)
(ietf-drums-init string)
@@ -236,7 +240,9 @@ the Content-Transfer-Encoding header of a mail."
(cons
(mapconcat 'identity (nreverse display-name) "")
(ietf-drums-get-comment string)))
- (cons mailbox display-string)))))
+ (cons mailbox (if decode
+ (rfc2047-decode-string display-string)
+ display-string))))))
(defun ietf-drums-parse-addresses (string &optional rawp)
"Parse STRING and return a list of MAILBOX / DISPLAY-NAME pairs.
@@ -288,7 +294,7 @@ a list of address strings."
(defun ietf-drums-parse-date (string)
"Return an Emacs time spec from STRING."
- (apply 'encode-time (parse-time-string string)))
+ (encode-time (parse-time-string string)))
(defun ietf-drums-narrow-to-header ()
"Narrow to the header section in the current buffer."
diff --git a/lisp/mail/mail-extr.el b/lisp/mail/mail-extr.el
index 9fcc2707d75..c1e90c3dcb8 100644
--- a/lisp/mail/mail-extr.el
+++ b/lisp/mail/mail-extr.el
@@ -293,7 +293,7 @@ by translating things like \"foo!bar!baz@host\" into \"baz@bar.UUCP\"."
;; multipart names.
;; #### should . be in here?
(defconst mail-extr-all-letters
- (purecopy (concat mail-extr-all-letters-but-separators "---")))
+ (purecopy (concat mail-extr-all-letters-but-separators "-")))
;; Any character that can start a name.
;; Keep this set as minimal as possible.
@@ -305,19 +305,11 @@ by translating things like \"foo!bar!baz@host\" into \"baz@bar.UUCP\"."
(defconst mail-extr-leading-garbage "\\W+")
-;; (defconst mail-extr-non-name-chars
-;; (purecopy (concat "^" mail-extr-all-letters ".")))
;; (defconst mail-extr-non-begin-name-chars
;; (purecopy (concat "^" mail-extr-first-letters)))
;; (defconst mail-extr-non-end-name-chars
;; (purecopy (concat "^" mail-extr-last-letters)))
-;; Matches an initial not followed by both a period and a space.
-;; (defconst mail-extr-bad-initials-pattern
-;; (purecopy
-;; (format "\\(\\([^%s]\\|\\`\\)[%s]\\)\\(\\.\\([^ ]\\)\\| \\|\\([^%s .]\\)\\|\\'\\)"
-;; mail-extr-all-letters mail-extr-first-letters mail-extr-all-letters)))
-
;; Matches periods used instead of spaces. Must not match the period
;; following an initial.
(defconst mail-extr-bad-dot-pattern
@@ -391,7 +383,7 @@ by translating things like \"foo!bar!baz@host\" into \"baz@bar.UUCP\"."
;; Matches telephone extensions.
(defconst mail-extr-telephone-extension-pattern
(purecopy
- "\\(\\([Ee]xt\\|\\|[Tt]ph\\|[Tt]el\\|[Xx]\\).?\\)? *\\+?[0-9][- 0-9]+"))
+ "\\(\\([Ee]xt\\|[Tt]ph\\|[Tt]el\\|[Xx]\\)\\.?\\)? *\\+?[0-9][- 0-9]+"))
;; Matches ham radio call signs.
;; Help from: Mat Maessen N2NJZ <maessm@rpi.edu>, Mark Feit
@@ -654,7 +646,7 @@ Unless NO-REPLACE is true, at each of the positions in LIST-SYMBOL
(< ch ,beg-symbol))
,@(if no-replace
nil
- `((mail-extr-nuke-char-at ch)))
+ '((mail-extr-nuke-char-at ch)))
(setcar temp nil))
(setq temp (cdr temp)))
(setq ,list-symbol (delq nil ,list-symbol))))
@@ -715,7 +707,13 @@ one recipients, all but the first is ignored.
ADDRESS may be a string or a buffer. If it is a buffer, the visible
\(narrowed) portion of the buffer will be interpreted as the address.
\(This feature exists so that the clever caller might be able to avoid
-consing a string.)"
+consing a string.)
+
+This function is primarily meant for when you're displaying the
+result to the user: Many prettifications are applied to the
+result returned. If you want to decode an address for further
+non-display use, you should probably use
+`mail-header-parse-address' instead."
(let ((canonicalization-buffer (get-buffer-create " *canonical address*"))
(extraction-buffer (get-buffer-create " *extract address components*"))
value-list)
diff --git a/lisp/mail/mail-utils.el b/lisp/mail/mail-utils.el
index 0d489499f59..cbcbdfaeb2e 100644
--- a/lisp/mail/mail-utils.el
+++ b/lisp/mail/mail-utils.el
@@ -41,7 +41,7 @@ often correct parser."
If this is nil, it is set the first time you compose a reply, to
a value which excludes your own email address.
-Matching addresses are excluded from the CC field in replies, and
+Matching addresses are excluded from the Cc field in replies, and
also the To field, unless this would leave an empty To field."
:type '(choice regexp (const :tag "Your Name" nil))
:group 'mail)
diff --git a/lisp/mail/mailabbrev.el b/lisp/mail/mailabbrev.el
index ee48b2cd021..d59df88c688 100644
--- a/lisp/mail/mailabbrev.el
+++ b/lisp/mail/mailabbrev.el
@@ -25,7 +25,7 @@
;;; Commentary:
-;; This file ensures that, when the point is in a To:, CC:, BCC:, or From:
+;; This file ensures that, when the point is in a To:, Cc:, Bcc:, or From:
;; field, word-abbrevs are defined for each of your mail aliases. These
;; aliases will be defined from your .mailrc file (or the file specified by
;; `mail-personal-alias-file') if it exists. Your mail aliases will
@@ -134,9 +134,6 @@
;;;###autoload
(define-minor-mode mail-abbrevs-mode
"Toggle abbrev expansion of mail aliases (Mail Abbrevs mode).
-With a prefix argument ARG, enable Mail Abbrevs mode if ARG is
-positive, and disable it otherwise. If called from Lisp, enable
-the mode if ARG is omitted or nil.
Mail Abbrevs mode is a global minor mode. When enabled,
abbrev-like expansion is performed when editing certain mail
@@ -166,7 +163,8 @@ no aliases, which is represented by this being a table with no entries.)")
(defun mail-abbrevs-sync-aliases ()
(when mail-personal-alias-file
(if (file-exists-p mail-personal-alias-file)
- (let ((modtime (nth 5 (file-attributes mail-personal-alias-file))))
+ (let ((modtime (file-attribute-modification-time
+ (file-attributes mail-personal-alias-file))))
(if (not (equal mail-abbrev-modtime modtime))
(progn
(setq mail-abbrev-modtime modtime)
@@ -179,7 +177,8 @@ no aliases, which is represented by this being a table with no entries.)")
(file-exists-p mail-personal-alias-file))
(progn
(setq mail-abbrev-modtime
- (nth 5 (file-attributes mail-personal-alias-file)))
+ (file-attribute-modification-time
+ (file-attributes mail-personal-alias-file)))
(build-mail-abbrevs)))
(mail-abbrevs-sync-aliases)
(add-function :around (local 'abbrev-expand-function)
@@ -414,7 +413,7 @@ with a space."
;;; Syntax tables and abbrev-expansion
(defcustom mail-abbrev-mode-regexp
- "^\\(Resent-\\)?\\(To\\|From\\|CC\\|BCC\\|Reply-to\\):"
+ "^\\(Resent-\\)?\\(To\\|From\\|Cc\\|Bcc\\|Reply-To\\):"
"Regexp matching mail headers in which mail abbrevs should be expanded.
This string will be handed to `looking-at' with point at the beginning
of the current line; if it matches, abbrev mode will be turned on, otherwise
@@ -477,7 +476,7 @@ of a mail alias. The value is set up, buffer-local, when first needed.")
;; Necessary for `message-read-from-minibuffer' to work.
(window-minibuffer-p))
- ;; We are in a To: (or CC:, or whatever) header or a minibuffer,
+ ;; We are in a To: (or Cc:, or whatever) header or a minibuffer,
;; and should use word-abbrevs to expand mail aliases.
(let ((local-abbrev-table mail-abbrevs))
diff --git a/lisp/mail/mailalias.el b/lisp/mail/mailalias.el
index 981f1450da7..8bb42634892 100644
--- a/lisp/mail/mailalias.el
+++ b/lisp/mail/mailalias.el
@@ -50,14 +50,18 @@
When t this still needs to be initialized.")
(defvar mail-address-field-regexp
- "^\\(Resent-\\)?\\(To\\|From\\|CC\\|BCC\\|Reply-to\\):")
+ "^\\(Resent-\\)?\\(To\\|From\\|Cc\\|Bcc\\|Reply-To\\):")
-(defvar pattern)
+;; `pattern' is bound dynamically before evaluating the forms in
+;; `mail-complete-alist' and may be part of user customizations of
+;; that variable.
+(with-suppressed-warnings ((lexical pattern))
+ (defvar pattern))
(defcustom mail-complete-alist
;; Don't refer to mail-address-field-regexp here;
;; that confuses some things such as cus-dep.el.
- '(("^\\(Resent-\\)?\\(To\\|From\\|CC\\|BCC\\|Reply-to\\):"
+ '(("^\\(Resent-\\)?\\(To\\|From\\|Cc\\|Bcc\\|Reply-To\\):"
. (mail-get-names pattern))
("Newsgroups:" . (if (boundp 'gnus-active-hashtb)
gnus-active-hashtb
@@ -169,7 +173,7 @@ When t this still needs to be initialized.")
(defun expand-mail-aliases (beg end &optional exclude)
"Expand all mail aliases in suitable header fields found between BEG and END.
If interactive, expand in header fields.
-Suitable header fields are `To', `From', `CC' and `BCC', `Reply-to', and
+Suitable header fields are `To', `From', `Cc' and `Bcc', `Reply-To', and
their `Resent-' variants.
Optional second arg EXCLUDE may be a regular expression defining text to be
diff --git a/lisp/mail/mailheader.el b/lisp/mail/mailheader.el
index 936f53e96a5..8aec1940a7e 100644
--- a/lisp/mail/mailheader.el
+++ b/lisp/mail/mailheader.el
@@ -99,7 +99,8 @@ value."
headers)
;; Advertised part of the interface; see mail-header, mail-header-set.
-(defvar headers)
+(with-suppressed-warnings ((lexical headers))
+ (defvar headers))
(defsubst mail-header (header &optional header-alist)
"Return the value associated with header HEADER in HEADER-ALIST.
diff --git a/lisp/mail/mspools.el b/lisp/mail/mspools.el
index 9aaf86d401c..b1cbd9e5497 100644
--- a/lisp/mail/mspools.el
+++ b/lisp/mail/mspools.el
@@ -3,7 +3,6 @@
;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
;; Author: Stephen Eglen <stephen@gnu.org>
-;; Maintainer: Stephen Eglen <stephen@gnu.org>
;; Created: 22 Jan 1997
;; Keywords: mail
;; location: http://www.anc.ed.ac.uk/~stephen/emacs/
@@ -387,7 +386,7 @@ nil."
(let ((file (concat mspools-folder-directory spool))
size)
(setq file (or (file-symlink-p file) file))
- (setq size (nth 7 (file-attributes file)))
+ (setq size (file-attribute-size (file-attributes file)))
;; size could be nil if the sym-link points to a non-existent file
;; so check this first.
(if (and size (> size 0))
diff --git a/lisp/mail/qp.el b/lisp/mail/qp.el
index 5b497411886..803d78602e5 100644
--- a/lisp/mail/qp.el
+++ b/lisp/mail/qp.el
@@ -115,8 +115,7 @@ encode lines starting with \"From\"."
(setq class "\010-\012\014\040-\074\076-\177"))
(save-excursion
(goto-char from)
- (if (re-search-forward (string-to-multibyte "[^\x0-\x7f\x80-\xff]")
- to t)
+ (if (re-search-forward "[^\x0-\x7f\x80-\xff]" to t)
(error "Multibyte character in QP encoding region"))
(save-restriction
(narrow-to-region from to)
diff --git a/lisp/mail/rfc2047.el b/lisp/mail/rfc2047.el
index a1c65cbe930..118ca8a4c9b 100644
--- a/lisp/mail/rfc2047.el
+++ b/lisp/mail/rfc2047.el
@@ -290,11 +290,10 @@ Should be called narrowed to the head of the message."
(let ((rfc2047-encoding-type 'mime))
(rfc2047-encode-region (point) (point-max))))
((eq method 'default)
- (if (and (default-value 'enable-multibyte-characters)
- mail-parse-charset)
+ (if mail-parse-charset
(encode-coding-region (point) (point-max)
mail-parse-charset)))
- ;; We get this when CC'ing messages to newsgroups with
+ ;; We get this when Cc'ing messages to newsgroups with
;; 8-bit names. The group name mail copy just got
;; unconditionally encoded. Previously, it would ask
;; whether to encode, which was quite confusing for the
@@ -305,18 +304,17 @@ Should be called narrowed to the head of the message."
;; in accordance with changes elsewhere.
((null method)
(rfc2047-encode-region (point) (point-max)))
-;;; ((null method)
-;;; (if (or (message-options-get
-;;; 'rfc2047-encode-message-header-encode-any)
-;;; (message-options-set
-;;; 'rfc2047-encode-message-header-encode-any
-;;; (y-or-n-p
-;;; "Some texts are not encoded. Encode anyway?")))
-;;; (rfc2047-encode-region (point-min) (point-max))
-;;; (error "Cannot send unencoded text")))
+ ;; ((null method)
+ ;; (if (or (message-options-get
+ ;; 'rfc2047-encode-message-header-encode-any)
+ ;; (message-options-set
+ ;; 'rfc2047-encode-message-header-encode-any
+ ;; (y-or-n-p
+ ;; "Some texts are not encoded. Encode anyway?")))
+ ;; (rfc2047-encode-region (point-min) (point-max))
+ ;; (error "Cannot send unencoded text")))
((mm-coding-system-p method)
- (when (default-value 'enable-multibyte-characters)
- (encode-coding-region (point) (point-max) method)))
+ (encode-coding-region (point) (point-max) method))
;; Hm.
(t)))
(goto-char (point-max))))))))
diff --git a/lisp/mail/rfc2231.el b/lisp/mail/rfc2231.el
index 31112a7505a..0a0983c25f8 100644
--- a/lisp/mail/rfc2231.el
+++ b/lisp/mail/rfc2231.el
@@ -1,4 +1,4 @@
-;;; rfc2231.el --- Functions for decoding rfc2231 headers
+;;; rfc2231.el --- Functions for decoding rfc2231 headers -*- lexical-binding:t -*-
;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
@@ -22,7 +22,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(require 'ietf-drums)
(require 'rfc2047)
(autoload 'mm-encode-body "mm-bodies")
@@ -181,7 +181,7 @@ must never cause a Lisp error."
;; Now collect and concatenate continuation parameters.
(let ((cparams nil)
elem)
- (loop for (attribute value part encoded)
+ (cl-loop for (attribute value part encoded)
in (sort parameters (lambda (e1 e2)
(< (or (caddr e1) 0)
(or (caddr e2) 0))))
@@ -291,7 +291,7 @@ the result of this function."
(insert param "*=")
(while (not (eobp))
(insert (if (>= num 0) " " "")
- param "*" (format "%d" (incf num)) "*=")
+ param "*" (format "%d" (cl-incf num)) "*=")
(forward-line 1))))
(spacep
(goto-char (point-min))
diff --git a/lisp/mail/rmail-spam-filter.el b/lisp/mail/rmail-spam-filter.el
index 36e50693fb1..86217e5dd5c 100644
--- a/lisp/mail/rmail-spam-filter.el
+++ b/lisp/mail/rmail-spam-filter.el
@@ -251,7 +251,7 @@ it from rmail file. Called for each new message retrieved by
(setq message-subject (mail-fetch-field "Subject"))
(setq message-content-type (mail-fetch-field "Content-Type"))
(setq message-spam-status (mail-fetch-field "X-Spam-Status")))
- ;; Check for blind CC condition. Set vars such that while
+ ;; Check for blind cc condition. Set vars such that while
;; loop will be bypassed and spam condition will trigger.
(and rsf-no-blind-cc
(null message-recipients)
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index a740c4bfa23..91291b8d330 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -191,9 +191,6 @@ Its name should end with a slash."
:group 'rmail-retrieve
:type '(choice (const nil) string))
-(define-obsolete-variable-alias 'rmail-pop-password
- 'rmail-remote-password "22.1")
-
(defcustom rmail-remote-password nil
"Password to use when reading mail from a remote server.
This setting is ignored for mailboxes whose URL already contains a password."
@@ -202,9 +199,6 @@ This setting is ignored for mailboxes whose URL already contains a password."
:group 'rmail-retrieve
:version "22.1")
-(define-obsolete-variable-alias 'rmail-pop-password-required
- 'rmail-remote-password-required "22.1")
-
(defcustom rmail-remote-password-required nil
"Non-nil if a password is required when reading mail from a remote server."
:type 'boolean
@@ -857,7 +851,7 @@ that knows the exact ordering of the \\( \\) subexpressions.")
(beginning-of-line) (end-of-line)
(1 font-lock-comment-delimiter-face nil t)
(5 font-lock-comment-face nil t)))
- '("^\\(X-[a-z0-9-]+\\|In-reply-to\\|Date\\):.*\\(\n[ \t]+.*\\)*$"
+ '("^\\(X-[a-z0-9-]+\\|In-Reply-To\\|Date\\):.*\\(\n[ \t]+.*\\)*$"
. 'rmail-header-name))))
"Additional expressions to highlight in Rmail mode.")
@@ -1331,8 +1325,7 @@ Instead, these commands are available:
(let ((finding-rmail-file (not (eq major-mode 'rmail-mode))))
(rmail-mode-2)
(when (and finding-rmail-file
- (null coding-system-for-read)
- (default-value 'enable-multibyte-characters))
+ (null coding-system-for-read))
(let ((rmail-enable-multibyte t))
(rmail-require-mime-maybe)
(rmail-convert-file-maybe)
@@ -1759,7 +1752,7 @@ not be a new one). It returns non-nil if it got any new messages."
(or (eq buffer-undo-list t)
(setq buffer-undo-list nil))
(let ((all-files (if file-name (list file-name) rmail-inbox-list))
- (rmail-enable-multibyte (default-value 'enable-multibyte-characters))
+ (rmail-enable-multibyte t)
found)
(unwind-protect
(progn
@@ -2035,10 +2028,10 @@ Value is the size of the newly read mail after conversion."
"the remote server"
proto)))
((and (file-exists-p tofile)
- (/= 0 (nth 7 (file-attributes tofile))))
+ (/= 0 (file-attribute-size (file-attributes tofile))))
(message "Getting mail from %s..." tofile))
((and (file-exists-p file)
- (/= 0 (nth 7 (file-attributes file))))
+ (/= 0 (file-attribute-size (file-attributes file))))
(message "Getting mail from %s..." file)))
;; Set TOFILE if have not already done so, and
;; rename or copy the file FILE to TOFILE if and as appropriate.
@@ -2582,7 +2575,7 @@ the message. Point is at the beginning of the message."
(save-excursion
(setq deleted-head
(cons (if (and (search-forward (concat rmail-attribute-header ": ") message-end t)
- (looking-at "?D"))
+ (looking-at "\\?D"))
?D
?\s) deleted-head))))
@@ -3400,21 +3393,15 @@ Interactively, empty argument means use same regexp used last time."
(defun rmail-simplified-subject (&optional msgnum)
"Return the simplified subject of message MSGNUM (or current message).
-Simplifying the subject means stripping leading and trailing whitespace,
-and typical reply prefixes such as Re:."
- (let ((subject (or (rmail-get-header "Subject" msgnum) "")))
+Simplifying the subject means stripping leading and trailing
+whitespace, replacing whitespace runs with a single space and
+removing prefixes such as Re:, Fwd: and so on and mailing list
+tags such as [tag]."
+ (let ((subject (or (rmail-get-header "Subject" msgnum) ""))
+ (regexp "\\`[ \t\n]*\\(\\(\\w\\{1,3\\}:\\|\\[[^]]+]\\)[ \t\n]+\\)*"))
(setq subject (rfc2047-decode-string subject))
- (if (string-match "\\`[ \t]+" subject)
- (setq subject (substring subject (match-end 0))))
- (if (string-match rmail-reply-regexp subject)
- (setq subject (substring subject (match-end 0))))
- (if (string-match "[ \t]+\\'" subject)
- (setq subject (substring subject 0 (match-beginning 0))))
- ;; If Subject is long, mailers will break it into several lines at
- ;; arbitrary places, so normalize whitespace by replacing every
- ;; run of whitespace characters with a single space.
- (setq subject (replace-regexp-in-string "[ \t\n]+" " " subject))
- subject))
+ (setq subject (replace-regexp-in-string regexp "" subject))
+ (replace-regexp-in-string "[ \t\n]+" " " subject)))
(defun rmail-simplified-subject-regexp ()
"Return a regular expression matching the current simplified subject.
@@ -3803,7 +3790,7 @@ original message into it."
(defun rmail-reply (just-sender)
"Reply to the current message.
-Normally include CC: to all other recipients of original message;
+Normally include Cc: to all other recipients of original message;
prefix argument means ignore them. While composing the reply,
use \\[mail-yank-original] to yank the original message into it."
(interactive "P")
@@ -3837,7 +3824,7 @@ use \\[mail-yank-original] to yank the original message into it."
(unless just-sender
(if (mail-fetch-field "mail-followup-to" nil t)
;; If this header field is present, use it instead of the
- ;; To and CC fields.
+ ;; To and Cc fields.
(setq to (mail-fetch-field "mail-followup-to" nil t))
(setq cc (or (mail-fetch-field "cc" nil t) "")
to (or (mail-fetch-field "to" nil t) ""))))))
@@ -4140,6 +4127,7 @@ typically for purposes of moderating a list."
"^ *---+ +Original message follows +---+ *$\\|"
"^ *---+ +Your message follows +---+ *$\\|"
"^|? *---+ +Message text follows: +---+ *|?$\\|"
+ "^ *---+ +This is a copy of \\w+ message, including all the headers.*---+ *\n *---+ +The body of the message is [0-9]+ characters long; only the first *\n *---+ +[0-9]+ or so are included here\\. *$\\|"
"^ *---+ +This is a copy of \\w+ message, including all the headers.*---+ *$")
"A regexp that matches the separator before the text of a failed message.")
@@ -4288,7 +4276,7 @@ specifying headers which should not be copied into the new message."
(if mail-self-blind
(if resending
(insert "Resent-Bcc: " (user-login-name) "\n")
- (insert "BCC: " (user-login-name) "\n"))))
+ (insert "Bcc: " (user-login-name) "\n"))))
(goto-char (point-min))
(mail-position-on-field (if resending "Resent-To" "To") t))))))
@@ -4528,7 +4516,7 @@ encoded string (and the same mask) will decode the string."
(if (= curmask 0)
(setq curmask mask))
(setq charmask (% curmask 256))
- (setq curmask (lsh curmask -8))
+ (setq curmask (ash curmask -8))
(aset string-vector i (logxor charmask (aref string-vector i)))
(setq i (1+ i)))
(concat string-vector)))
@@ -4556,6 +4544,9 @@ Argument MIME is non-nil if this is a mime message."
(unless armor-end
(error "Encryption armor beginning has no matching end"))
+ (setq armor-start (move-marker (make-marker) armor-start))
+ (setq armor-end (move-marker (make-marker) armor-end))
+
(goto-char armor-start)
;; Because epa--find-coding-system-for-mime-charset not autoloaded.
@@ -4588,15 +4579,16 @@ Argument MIME is non-nil if this is a mime message."
(mail-unquote-printable-region armor-start
(- (point-max) after-end))))
- ;; Decrypt it, maybe in place, maybe making new buffer.
- (epa-decrypt-region
- armor-start (- (point-max) after-end)
- ;; Call back this function to prepare the output.
- (lambda ()
- (let ((inhibit-read-only t))
- (delete-region armor-start (- (point-max) after-end))
- (goto-char armor-start)
- (current-buffer))))
+ (condition-case nil
+ (epa-decrypt-region
+ armor-start (- (point-max) after-end)
+ ;; Call back this function to prepare the output.
+ (lambda ()
+ (let ((inhibit-read-only t))
+ (delete-region armor-start (- (point-max) after-end))
+ (goto-char armor-start)
+ (current-buffer))))
+ (error nil))
(list armor-start (- (point-max) after-end) mime
armor-end-regexp
@@ -4632,9 +4624,14 @@ Argument MIME is non-nil if this is a mime message."
(goto-char (point-min))
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
(let ((coding-system-for-read coding-system-for-read)
- (case-fold-search t))
-
- (push (rmail-epa-decrypt-1 mime) decrypts)))
+ (case-fold-search t)
+ (armor-start (match-beginning 0)))
+ ;; Don't decrypt an armor that was copied into
+ ;; the message from a message it is a reply to.
+ (or (equal (buffer-substring (line-beginning-position)
+ armor-start)
+ "> ")
+ (push (rmail-epa-decrypt-1 mime) decrypts))))
(when (and decrypts (eq major-mode 'rmail-mode))
(rmail-add-label "decrypt"))
diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el
index af528135ccb..95977e826d7 100644
--- a/lisp/mail/rmailmm.el
+++ b/lisp/mail/rmailmm.el
@@ -836,7 +836,8 @@ directly."
size (car bulk-data))
(if (stringp (aref body 0))
(setq data (aref body 0))
- (setq data (string-as-unibyte (buffer-string)))
+ (setq data (buffer-string))
+ (cl-assert (not (multibyte-string-p data)))
(aset body 0 data)
(rmail-mime-set-bulk-data entity)
(delete-region (point-min) (point-max)))
diff --git a/lisp/mail/rmailout.el b/lisp/mail/rmailout.el
index 1a6f4e55fbc..12d37615d6b 100644
--- a/lisp/mail/rmailout.el
+++ b/lisp/mail/rmailout.el
@@ -56,6 +56,13 @@ The function `rmail-delete-unwanted-fields' uses this, ignoring case."
regexp)
:group 'rmail-output)
+(defcustom rmail-output-reset-deleted-flag nil
+ "Non-nil means reset the \"deleted\" flag when outputting a message to a file."
+ :type '(choice (const :tag "Output with the \"deleted\" flag reset" t)
+ (const :tag "Output with the \"deleted\" flag intact" nil))
+ :version "27.1"
+ :group 'rmail-output)
+
(defun rmail-output-read-file-name ()
"Read the file name to use for `rmail-output'.
Set `rmail-default-file' to this name as well as returning it.
@@ -472,9 +479,15 @@ buffer, updates it accordingly.
This command always outputs the complete message header, even if
the header display is currently pruned.
+If `rmail-output-reset-deleted-flag' is non-nil, the message's
+deleted flag is reset in the message appended to the destination
+file. Otherwise, the appended message will remain marked as
+deleted if it was deleted before invoking this command.
+
Optional prefix argument COUNT (default 1) says to output that
many consecutive messages, starting with the current one (ignoring
-deleted messages). If `rmail-delete-after-output' is non-nil, deletes
+deleted messages, unless `rmail-output-reset-deleted-flag' is
+non-nil). If `rmail-delete-after-output' is non-nil, deletes
messages after output.
The optional third argument NOATTRIBUTE, if non-nil, says not to
@@ -533,30 +546,47 @@ from a non-Rmail buffer. In this case, COUNT is ignored."
(if (zerop rmail-total-messages)
(error "No messages to output"))
(let ((orig-count count)
- beg end)
+ beg end delete-attr-reset-p)
(while (> count 0)
- (setq beg (rmail-msgbeg rmail-current-message)
- end (rmail-msgend rmail-current-message))
- ;; All access to the buffer's local variables is now finished...
- (save-excursion
- ;; ... so it is ok to go to a different buffer.
- (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
- (setq cur (current-buffer))
- (save-restriction
- (widen)
- (with-temp-buffer
- (insert-buffer-substring cur beg end)
- (if babyl-format
- (rmail-output-as-babyl file-name noattribute)
- (rmail-output-as-mbox file-name noattribute)))))
+ (when (and rmail-output-reset-deleted-flag
+ (rmail-message-deleted-p rmail-current-message))
+ (rmail-set-attribute rmail-deleted-attr-index nil)
+ (setq delete-attr-reset-p t))
+ ;; Make sure we undo our messing with the DELETED attribute.
+ (unwind-protect
+ (progn
+ (setq beg (rmail-msgbeg rmail-current-message)
+ end (rmail-msgend rmail-current-message))
+ ;; All access to the buffer's local variables is now finished...
+ (save-excursion
+ ;; ... so it is ok to go to a different buffer.
+ (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
+ (setq cur (current-buffer))
+ (save-restriction
+ (widen)
+ (with-temp-buffer
+ (insert-buffer-substring cur beg end)
+ (if babyl-format
+ (rmail-output-as-babyl file-name noattribute)
+ (rmail-output-as-mbox file-name noattribute))))))
+ (if delete-attr-reset-p
+ (rmail-set-attribute rmail-deleted-attr-index t)))
(or noattribute ; mark message as "filed"
(rmail-set-attribute rmail-filed-attr-index t))
(setq count (1- count))
(let ((next-message-p
- (if rmail-delete-after-output
- (rmail-delete-forward)
- (if (> count 0)
- (rmail-next-undeleted-message 1))))
+ (if rmail-output-reset-deleted-flag
+ (progn
+ (if rmail-delete-after-output
+ (rmail-delete-message))
+ (if (> count 0)
+ (let ((msgnum rmail-current-message))
+ (rmail-next-message 1)
+ (eq rmail-current-message (1+ msgnum)))))
+ (if rmail-delete-after-output
+ (rmail-delete-forward)
+ (if (> count 0)
+ (rmail-next-undeleted-message 1)))))
(num-appended (- orig-count count)))
(if (and (> count 0) (not next-message-p))
(error "Only %d message%s appended" num-appended
diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el
index 2ed01a00df6..79a322c1d91 100644
--- a/lisp/mail/rmailsum.el
+++ b/lisp/mail/rmailsum.el
@@ -390,8 +390,17 @@ SUBJECT is a regular expression."
;;;###autoload
(defun rmail-summary-by-senders (senders)
"Display a summary of all messages whose \"From\" field matches SENDERS.
-SENDERS is a regular expression."
- (interactive "sSenders to summarize by: ")
+SENDERS is a regular expression. The default for SENDERS matches the
+sender of the current messsage."
+ (interactive
+ (let* ((def (rmail-get-header "From"))
+ ;; We quote the default argument, because if it contains regexp
+ ;; special characters (eg "?"), it can fail to match itself.
+ (sender (regexp-quote def))
+ (prompt (concat "Senders to summarize by (regexp"
+ (if sender ", default this message's sender" "")
+ "): ")))
+ (list (read-string prompt nil nil sender))))
(rmail-new-summary
(concat "senders " senders)
(list 'rmail-summary-by-senders senders) 'rmail-message-senders-p senders))
@@ -1306,11 +1315,7 @@ advance to the next message."
(select-window rmail-buffer-window)
(prog1
;; Is EOB visible in the buffer?
- (save-excursion
- (let ((ht (window-height)))
- (move-to-window-line (- ht 2))
- (end-of-line)
- (eobp)))
+ (pos-visible-in-window-p (point-max))
(select-window rmail-summary-window)))
(if (not rmail-summary-scroll-between-messages)
(error "End of buffer")
@@ -1333,10 +1338,7 @@ move to the previous message."
(select-window rmail-buffer-window)
(prog1
;; Is BOB visible in the buffer?
- (save-excursion
- (move-to-window-line 0)
- (beginning-of-line)
- (bobp))
+ (pos-visible-in-window-p (point-min))
(select-window rmail-summary-window)))
(if (not rmail-summary-scroll-between-messages)
(error "Beginning of buffer")
@@ -1626,7 +1628,7 @@ original message into it."
(defun rmail-summary-reply (just-sender)
"Reply to the current message.
-Normally include CC: to all other recipients of original message;
+Normally include Cc: to all other recipients of original message;
prefix argument means ignore them. While composing the reply,
use \\[mail-yank-original] to yank the original message into it."
(interactive "P")
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 21c85dae2cf..291efab961e 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -1,4 +1,4 @@
-;;; sendmail.el --- mail sending commands for Emacs
+;;; sendmail.el --- mail sending commands for Emacs -*- lexical-binding:t -*-
;; Copyright (C) 1985-1986, 1992-1996, 1998, 2000-2019 Free Software
;; Foundation, Inc.
@@ -55,7 +55,7 @@
:type 'file)
;;;###autoload
-(defcustom mail-from-style 'default
+(defcustom mail-from-style 'angles
"Specifies how \"From:\" fields look.
If nil, they contain just the return address like:
@@ -72,8 +72,11 @@ Otherwise, most addresses look like `angles', but they look like
(const parens)
(const angles)
(const default))
- :version "20.3"
+ :version "27.1"
:group 'sendmail)
+(make-obsolete-variable
+ 'mail-from-style
+ "only the `angles' value is valid according to RFC2822." "27.1" 'set)
;;;###autoload
(defcustom mail-specify-envelope-from nil
@@ -104,9 +107,9 @@ being sent is used), or nil (in which case the value of
;;;###autoload
(defcustom mail-self-blind nil
- "Non-nil means insert BCC to self in messages to be sent.
+ "Non-nil means insert Bcc to self in messages to be sent.
This is done when the message is initialized,
-so you can remove or alter the BCC field to override the default."
+so you can remove or alter the Bcc field to override the default."
:type 'boolean
:group 'sendmail)
@@ -185,7 +188,7 @@ be a Babyl file."
;;;###autoload
(defcustom mail-default-reply-to nil
- "Address to insert as default Reply-to field of outgoing messages.
+ "Address to insert as default Reply-To field of outgoing messages.
If nil, it will be initialized from the REPLYTO environment variable
when you first send mail."
:type '(choice (const nil) string)
@@ -243,15 +246,6 @@ Used by `mail-yank-original' via `mail-indent-citation'."
:type 'integer
:group 'sendmail)
-(defvar mail-yank-hooks nil
- "Obsolete hook for modifying a citation just inserted in the mail buffer.
-Each hook function can find the citation between (point) and (mark t).
-And each hook function should leave point and mark around the citation
-text as modified.
-This is a normal hook, misnamed for historical reasons.
-It is obsolete and mail agents should no longer use it.")
-(make-obsolete-variable 'mail-yank-hooks 'mail-citation-hook "19.34")
-
;;;###autoload
(defcustom mail-citation-hook nil
"Hook for modifying a citation just inserted in the mail buffer.
@@ -376,6 +370,7 @@ By default, this is the file specified by `mail-personal-alias-file'." t)
;;;###autoload
(defcustom mail-signature t
"Text inserted at end of mail buffer when a message is initialized.
+If nil, no signature is inserted.
If t, it means to insert the contents of the file `mail-signature-file'.
If a string, that string is inserted.
(To make a proper signature, the string should begin with \\n\\n-- \\n,
@@ -479,7 +474,7 @@ by Emacs.)")
(cite-prefix "[:alpha:]")
(cite-suffix (concat cite-prefix "0-9_.@-`'\"")))
(list '("^\\(To\\|Newsgroups\\):" . font-lock-function-name-face)
- '("^\\(B?CC\\|Reply-to\\|Mail-\\(reply\\|followup\\)-to\\):" . font-lock-keyword-face)
+ '("^\\(B?Cc\\|Reply-To\\|Mail-\\(Reply\\|Followup\\)-To\\):" . font-lock-keyword-face)
'("^\\(Subject:\\)[ \t]*\\(.+\\)?"
(1 font-lock-comment-face)
;; (2 font-lock-type-face nil t)
@@ -499,7 +494,7 @@ by Emacs.)")
(beginning-of-line) (end-of-line)
(1 font-lock-comment-delimiter-face nil t)
(5 font-lock-comment-face nil t)))
- '("^\\(X-[A-Za-z0-9-]+\\|In-reply-to\\):.*\\(\n[ \t]+.*\\)*$"
+ '("^\\(X-[A-Za-z0-9-]+\\|In-Reply-To\\):.*\\(\n[ \t]+.*\\)*$"
. font-lock-string-face))))
"Additional expressions to highlight in Mail mode.")
@@ -511,9 +506,13 @@ This also saves the value of `send-mail-function' via Customize."
;; If send-mail-function is already setup, we're incorrectly called
;; a second time, probably because someone's using an old value
;; of send-mail-function.
- (when (eq send-mail-function 'sendmail-query-once)
- (sendmail-query-user-about-smtp))
- (funcall send-mail-function))
+ (if (not (eq send-mail-function 'sendmail-query-once))
+ (funcall send-mail-function)
+ (let ((function (sendmail-query-user-about-smtp)))
+ (funcall function)
+ (when (y-or-n-p "Save this mail sending choice?")
+ (setq send-mail-function function)
+ (customize-save-variable 'send-mail-function function)))))
(defun sendmail-query-user-about-smtp ()
(let* ((options `(("mail client" . mailclient-send-it)
@@ -558,12 +557,13 @@ This also saves the value of `send-mail-function' via Customize."
(completing-read
(format "Send mail via (default %s): " (caar options))
options nil 'require-match nil nil (car options))))))
- (customize-save-variable 'send-mail-function
- (cdr (assoc-string choice options t)))))
+ ;; Return the choice.
+ (cdr (assoc-string choice options t))))
(defun sendmail-sync-aliases ()
(when mail-personal-alias-file
- (let ((modtime (nth 5 (file-attributes mail-personal-alias-file))))
+ (let ((modtime (file-attribute-modification-time
+ (file-attributes mail-personal-alias-file))))
(or (equal mail-alias-modtime modtime)
(setq mail-alias-modtime modtime
mail-aliases t)))))
@@ -616,7 +616,7 @@ This also saves the value of `send-mail-function' via Customize."
(kill-local-variable 'buffer-file-coding-system)
;; This doesn't work for enable-multibyte-characters.
;; (kill-local-variable 'enable-multibyte-characters)
- (set-buffer-multibyte (default-value 'enable-multibyte-characters))
+ (set-buffer-multibyte t)
(if current-input-method
(deactivate-input-method))
@@ -644,7 +644,7 @@ This also saves the value of `send-mail-function' via Customize."
(newline))
(if cc
(let ((fill-prefix "\t")
- (address-start (progn (insert "CC: ") (point))))
+ (address-start (progn (insert "Cc: ") (point))))
(insert cc "\n")
(fill-region-as-paragraph address-start (point-max))
(goto-char (point-max))
@@ -654,7 +654,7 @@ This also saves the value of `send-mail-function' via Customize."
(let ((fill-prefix "\t")
(fill-column 78)
(address-start (point)))
- (insert "In-reply-to: " in-reply-to "\n")
+ (insert "In-Reply-To: " in-reply-to "\n")
(fill-region-as-paragraph address-start (point-max))
(goto-char (point-max))
(unless (bolp)
@@ -663,11 +663,11 @@ This also saves the value of `send-mail-function' via Customize."
(if mail-default-headers
(insert mail-default-headers))
(if mail-default-reply-to
- (insert "Reply-to: " mail-default-reply-to "\n"))
+ (insert "Reply-To: " mail-default-reply-to "\n"))
(if mail-self-blind
- (insert "BCC: " user-mail-address "\n"))
+ (insert "Bcc: " user-mail-address "\n"))
(if mail-archive-file-name
- (insert "FCC: " mail-archive-file-name "\n"))
+ (insert "Fcc: " mail-archive-file-name "\n"))
(put-text-property (point)
(progn
(insert mail-header-separator "\n")
@@ -703,8 +703,8 @@ Like Text Mode but with these additional commands:
Here are commands that move to a header field (and create it if there isn't):
\\[mail-to] move to To: \\[mail-subject] move to Subj:
- \\[mail-bcc] move to BCC: \\[mail-cc] move to CC:
- \\[mail-fcc] move to FCC: \\[mail-reply-to] move to Reply-To:
+ \\[mail-bcc] move to Bcc: \\[mail-cc] move to Cc:
+ \\[mail-fcc] move to Fcc: \\[mail-reply-to] move to Reply-To:
\\[mail-mail-reply-to] move to Mail-Reply-To:
\\[mail-mail-followup-to] move to Mail-Followup-To:
\\[mail-text] move to message text.
@@ -786,8 +786,12 @@ Concretely: replace the first blank line in the header with the separator."
(defun mail-sendmail-undelimit-header ()
"Remove header separator to put the message in correct form for sendmail.
Leave point at the start of the delimiter line."
- (rfc822-goto-eoh)
- (delete-region (point) (progn (end-of-line) (point))))
+ (goto-char (point-min))
+ (when (re-search-forward
+ (concat "^" (regexp-quote mail-header-separator) "\n")
+ nil t)
+ (replace-match "\n"))
+ (rfc822-goto-eoh))
(defun mail-mode-auto-fill ()
"Carry out Auto Fill for Mail mode.
@@ -911,7 +915,7 @@ the user from the mailer."
(regexp-opt mail-mailing-lists t)
"\\(?:[[:space:];,]\\|\\'\\)"))))
(mail-combine-fields "To")
- (mail-combine-fields "CC")
+ (mail-combine-fields "Cc")
;; If there are mailing lists defined
(when ml
(save-excursion
@@ -1141,7 +1145,7 @@ to combine them into one, and does so if the user says y."
;; Try to preserve alignment of contents of the field
(let ((prefix-length (length (match-string 0))))
(replace-match " ")
- (dotimes (i (1- prefix-length))
+ (dotimes (_ (1- prefix-length))
(insert " ")))))))
(set-marker first-to-end nil))))))
@@ -1226,7 +1230,7 @@ external program defined by `sendmail-program'."
;; the message specially.
(let ((case-fold-search t))
(goto-char (point-min))
- (while (re-search-forward "^Resent-\\(to\\|cc\\|bcc\\):" delimline t)
+ (while (re-search-forward "^Resent-\\(To\\|Cc\\|Bcc\\):" delimline t)
;; Put a list of such addresses in resend-to-addresses.
(setq resend-to-addresses
(save-restriction
@@ -1238,7 +1242,7 @@ external program defined by `sendmail-program'."
(point)))
(append (mail-parse-comma-list)
resend-to-addresses)))
- ;; Delete Resent-BCC ourselves
+ ;; Delete Resent-Bcc ourselves
(if (save-excursion (beginning-of-line)
(looking-at "resent-bcc"))
(delete-region (line-beginning-position)
@@ -1301,9 +1305,9 @@ external program defined by `sendmail-program'."
(goto-char (1+ delimline))
(if (eval mail-mailer-swallows-blank-line)
(newline))
- ;; Find and handle any FCC fields.
+ ;; Find and handle any Fcc fields.
(goto-char (point-min))
- (if (re-search-forward "^FCC:" delimline t)
+ (if (re-search-forward "^Fcc:" delimline t)
(progn
(setq fcc-was-found t)
(mail-do-fcc delimline)))
@@ -1377,8 +1381,8 @@ external program defined by `sendmail-program'."
(autoload 'rmail-output-to-rmail-buffer "rmailout")
(defun mail-do-fcc (header-end)
- "Find and act on any FCC: headers in the current message before HEADER-END.
-If a buffer is visiting the FCC file, append to it before
+ "Find and act on any Fcc: headers in the current message before HEADER-END.
+If a buffer is visiting the Fcc file, append to it before
offering to save it, if it was modified initially. If this is an
Rmail buffer, update Rmail as needed. If there is no buffer,
just append to the file, in Babyl format if necessary."
@@ -1390,7 +1394,7 @@ just append to the file, in Babyl format if necessary."
(save-excursion
(goto-char (point-min))
(let ((case-fold-search t))
- (while (re-search-forward "^FCC:[ \t]*" header-end t)
+ (while (re-search-forward "^Fcc:[ \t]*" header-end t)
(push (buffer-substring (point)
(progn
(end-of-line)
@@ -1469,7 +1473,7 @@ just append to the file, in Babyl format if necessary."
;; If the file is a Babyl file, convert the message to
;; Babyl format. Even though Rmail no longer uses
;; Babyl, this code can remain for the time being, on
- ;; the off-chance one FCCs to a Babyl file that has
+ ;; the off-chance one Fccs to a Babyl file that has
;; not yet been converted to mbox.
(let ((coding-system-for-write
(or rmail-file-coding-system 'emacs-mule)))
@@ -1490,7 +1494,7 @@ just append to the file, in Babyl format if necessary."
(set-visited-file-modtime)))))))))
(defun mail-sent-via ()
- "Make a Sent-via header line from each To or CC header line."
+ "Make a Sent-via header line from each To or Cc header line."
(declare (obsolete "nobody can remember what it is for." "24.1"))
(interactive)
(save-excursion
@@ -1525,7 +1529,7 @@ just append to the file, in Babyl format if necessary."
(mail-position-on-field "Subject"))
(defun mail-cc ()
- "Move point to end of CC field, creating it if necessary."
+ "Move point to end of Cc field, creating it if necessary."
(interactive)
(expand-abbrev)
(or (mail-position-on-field "cc" t)
@@ -1533,20 +1537,20 @@ just append to the file, in Babyl format if necessary."
(insert "\nCC: "))))
(defun mail-bcc ()
- "Move point to end of BCC field, creating it if necessary."
+ "Move point to end of Bcc field, creating it if necessary."
(interactive)
(expand-abbrev)
(or (mail-position-on-field "bcc" t)
(progn (mail-position-on-field "to")
- (insert "\nBCC: "))))
+ (insert "\nBcc: "))))
(defun mail-fcc (folder)
- "Add a new FCC field, with file name completion."
+ "Add a new Fcc field, with file name completion."
(interactive "FFolder carbon copy: ")
(expand-abbrev)
- (or (mail-position-on-field "fcc" t) ;Put new field after exiting FCC.
+ (or (mail-position-on-field "fcc" t) ;Put new field after exiting Fcc.
(mail-position-on-field "to"))
- (insert "\nFCC: " folder))
+ (insert "\nFcc: " folder))
(defun mail-reply-to ()
"Move point to end of Reply-To field, creating it if necessary."
@@ -1717,8 +1721,6 @@ and don't delete any header fields."
(rfc822-goto-eoh)
(point))))))
(run-hooks 'mail-citation-hook)))
- (mail-yank-hooks
- (run-hooks 'mail-yank-hooks))
(t
(mail-indent-citation)))))
;; This is like exchange-point-and-mark, but doesn't activate the mark.
@@ -1787,9 +1789,7 @@ and don't delete any header fields."
(rfc822-goto-eoh)
(point))))))
(run-hooks 'mail-citation-hook))
- (if mail-yank-hooks
- (run-hooks 'mail-yank-hooks)
- (mail-indent-citation))))))))
+ (mail-indent-citation)))))))
(defun mail-split-line ()
"Split current line, moving portion beyond point vertically down.
@@ -1853,13 +1853,13 @@ Various special commands starting with C-c are available in sendmail mode
to move to message header fields:
\\{mail-mode-map}
-If `mail-self-blind' is non-nil, a BCC to yourself is inserted
+If `mail-self-blind' is non-nil, a Bcc to yourself is inserted
when the message is initialized.
If `mail-default-reply-to' is non-nil, it should be an address (a string);
-a Reply-to: field with that address is inserted.
+a Reply-To: field with that address is inserted.
-If `mail-archive-file-name' is non-nil, an FCC field with that file name
+If `mail-archive-file-name' is non-nil, an Fcc field with that file name
is inserted.
The normal hook `mail-setup-hook' is run after the message is
@@ -1958,6 +1958,7 @@ The seventh argument ACTIONS is a list of actions to take
;; Require dired so that dired-trivial-filenames does not get
;; unbound on exit from the let.
(require 'dired)
+ (defvar dired-trivial-filenames)
(let ((dired-trivial-filenames t))
(dired-other-window wildcard (concat dired-listing-switches " -t")))
(rename-buffer "*Auto-saved Drafts*" t)
@@ -2077,9 +2078,4 @@ you can move to one of them and type C-c C-c to recover that one."
;; Do not add anything but external entries on this page.
(provide 'sendmail)
-
-;; Local Variables:
-;; byte-compile-dynamic: t
-;; End:
-
;;; sendmail.el ends here
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index 5502e7cfa64..741c4393e65 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -1,9 +1,9 @@
-;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail
+;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail -*- lexical-binding:t -*-
;; Copyright (C) 1995-1996, 2001-2019 Free Software Foundation, Inc.
;; Author: Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp>
-;; Maintainer: Simon Josefsson <simon@josefsson.org>
+;; Maintainer: emacs-devel@gnu.org
;; w32 Maintainer: Brian D. Carlstrom <bdc@ai.mit.edu>
;; ESMTP support: Simon Leinen <simon@switch.ch>
;; Hacked by Mike Taylor, 11th October 1999 to add support for
@@ -138,7 +138,7 @@ The commands enables verbose information from the SMTP server."
(defcustom smtpmail-code-conv-from nil
"Coding system for encoding outgoing mail.
Used for the value of `sendmail-coding-system' when
-`select-message-coding-system' is called. "
+`select-message-coding-system' is called."
:type 'coding-system
:group 'smtpmail)
@@ -150,7 +150,8 @@ and sent with `smtpmail-send-queued-mail'."
:group 'smtpmail)
(defcustom smtpmail-queue-dir "~/Mail/queued-mail/"
- "Directory where `smtpmail.el' stores queued mail."
+ "Directory where `smtpmail.el' stores queued mail.
+This directory should not be writable by other users."
:type 'directory
:group 'smtpmail)
@@ -179,9 +180,11 @@ This is relative to `smtpmail-queue-dir'."
;; Buffer-local variable.
(defvar smtpmail-read-point)
-(defconst smtpmail-auth-supported '(cram-md5 plain login)
+(defvar smtpmail-auth-supported '(cram-md5 plain login)
"List of supported SMTP AUTH mechanisms.
-The list is in preference order.")
+The list is in preference order.
+Every element should have a matching `cl-defmethod' for
+for `smtpmail-try-auth-method'.")
(defvar smtpmail-mail-address nil
"Value to use for envelope-from address for mail from ambient buffer.")
@@ -320,11 +323,11 @@ The list is in preference order.")
(goto-char (1+ delimline))
(if (eval mail-mailer-swallows-blank-line)
(newline))
- ;; Find and handle any FCC fields.
+ ;; Find and handle any Fcc fields.
(goto-char (point-min))
- (if (re-search-forward "^FCC:" delimline t)
+ (if (re-search-forward "^Fcc:" delimline t)
;; Force `mail-do-fcc' to use the encoding of the mail
- ;; buffer to encode outgoing messages on FCC files.
+ ;; buffer to encode outgoing messages on Fcc files.
(let ((coding-system-for-write
;; mbox files must have Unix EOLs.
(coding-system-change-eol-conversion
@@ -359,9 +362,7 @@ The list is in preference order.")
smtpmail-queue-dir))
(file-data (convert-standard-filename file-data))
(file-elisp (concat file-data ".el"))
- (buffer-data (create-file-buffer file-data))
- (buffer-elisp (create-file-buffer file-elisp))
- (buffer-scratch "*queue-mail*"))
+ (buffer-data (create-file-buffer file-data)))
(unless (file-exists-p smtpmail-queue-dir)
(make-directory smtpmail-queue-dir t))
(with-current-buffer buffer-data
@@ -376,22 +377,16 @@ The list is in preference order.")
nil t)
(insert-buffer-substring tembuf)
(write-file file-data)
- (set-buffer buffer-elisp)
- (erase-buffer)
- (insert (concat
- "(setq smtpmail-recipient-address-list '"
+ (write-region
+ (concat "(setq smtpmail-recipient-address-list '"
(prin1-to-string smtpmail-recipient-address-list)
- ")\n"))
- (write-file file-elisp)
- (set-buffer (generate-new-buffer buffer-scratch))
- (insert (concat file-data "\n"))
- (append-to-file (point-min)
- (point-max)
- (expand-file-name smtpmail-queue-index-file
- smtpmail-queue-dir)))
- (kill-buffer buffer-scratch)
- (kill-buffer buffer-data)
- (kill-buffer buffer-elisp))))
+ ")\n")
+ nil file-elisp nil 'silent)
+ (write-region (concat file-data "\n") nil
+ (expand-file-name smtpmail-queue-index-file
+ smtpmail-queue-dir)
+ t 'silent))
+ (kill-buffer buffer-data))))
(kill-buffer tembuf)
(if (bufferp errbuf)
(kill-buffer errbuf)))))
@@ -412,7 +407,20 @@ The list is in preference order.")
(while (not (eobp))
(setq file-data (buffer-substring (point) (line-end-position)))
(setq file-elisp (concat file-data ".el"))
- (load file-elisp)
+ ;; FIXME: Avoid `load' which can execute arbitrary code and is hence
+ ;; a source of security holes. Better read the file and extract the
+ ;; data "by hand".
+ ;;(load file-elisp)
+ (with-temp-buffer
+ (insert-file-contents file-elisp)
+ (goto-char (point-min))
+ (pcase (read (current-buffer))
+ (`(setq smtpmail-recipient-address-list ',v)
+ (skip-chars-forward " \n\t")
+ (unless (eobp) (message "Ignoring trailing text in %S"
+ file-elisp))
+ (setq smtpmail-recipient-address-list v))
+ (sexp (error "Unexpected code in %S: %S" file-elisp sexp))))
;; Insert the message literally: it is already encoded as per
;; the MIME headers, and code conversions might guess the
;; encoding wrongly.
@@ -510,8 +518,7 @@ The list is in preference order.")
(user (plist-get auth-info :user))
(password (plist-get auth-info :secret))
(save-function (and ask-for-password
- (plist-get auth-info :save-function)))
- ret)
+ (plist-get auth-info :save-function))))
(when (functionp password)
(setq password (funcall password)))
(when (and user
@@ -532,7 +539,10 @@ The list is in preference order.")
(when (functionp password)
(setq password (funcall password)))
(let ((result (catch 'done
- (smtpmail-try-auth-method process mech user password))))
+ (if (and mech user password)
+ (smtpmail-try-auth-method process mech user password)
+ ;; No mechanism, or no credentials.
+ mech))))
(if (stringp result)
(progn
(auth-source-forget+ :host host :port port)
@@ -541,51 +551,52 @@ The list is in preference order.")
(funcall save-function))
result))))
-(defun smtpmail-try-auth-method (process mech user password)
- (let (ret)
- (cond
- ((or (not mech)
- (not user)
- (not password))
- ;; No mechanism, or no credentials.
- mech)
- ((eq mech 'cram-md5)
- (setq ret (smtpmail-command-or-throw process "AUTH CRAM-MD5"))
- (when (eq (car ret) 334)
- (let* ((challenge (substring (cadr ret) 4))
- (decoded (base64-decode-string challenge))
- (hash (rfc2104-hash 'md5 64 16 password decoded))
- (response (concat user " " hash))
- ;; Osamu Yamane <yamane@green.ocn.ne.jp>:
- ;; SMTP auth fails because the SMTP server identifies
- ;; only the first part of the string (delimited by
- ;; new line characters) as a response from the
- ;; client, and the rest as distinct commands.
-
- ;; In my case, the response string is 80 characters
- ;; long. Without the no-line-break option for
- ;; `base64-encode-string', only the first 76 characters
- ;; are taken as a response to the server, and the
- ;; authentication fails.
- (encoded (base64-encode-string response t)))
- (smtpmail-command-or-throw process encoded))))
- ((eq mech 'login)
- (smtpmail-command-or-throw process "AUTH LOGIN")
- (smtpmail-command-or-throw process (base64-encode-string user t))
- (smtpmail-command-or-throw process (base64-encode-string password t)))
- ((eq mech 'plain)
- ;; We used to send an empty initial request, and wait for an
- ;; empty response, and then send the password, but this
- ;; violate a SHOULD in RFC 2222 paragraph 5.1. Note that this
- ;; is not sent if the server did not advertise AUTH PLAIN in
- ;; the EHLO response. See RFC 2554 for more info.
- (smtpmail-command-or-throw
- process
- (concat "AUTH PLAIN "
- (base64-encode-string (concat "\0" user "\0" password) t))
- 235))
- (t
- (error "Mechanism %s not implemented" mech)))))
+(cl-defgeneric smtpmail-try-auth-method (_process mech _user _password)
+ "Perform authentication of type MECH for USER with PASSWORD.
+MECH should be one of the values in `smtpmail-auth-supported'.
+USER and PASSWORD should be non-nil."
+ (error "Mechanism %S not implemented" mech))
+
+(cl-defmethod smtpmail-try-auth-method
+ (process (_mech (eql cram-md5)) user password)
+ (let ((ret (smtpmail-command-or-throw process "AUTH CRAM-MD5")))
+ (when (eq (car ret) 334)
+ (let* ((challenge (substring (cadr ret) 4))
+ (decoded (base64-decode-string challenge))
+ (hash (rfc2104-hash 'md5 64 16 password decoded))
+ (response (concat user " " hash))
+ ;; Osamu Yamane <yamane@green.ocn.ne.jp>:
+ ;; SMTP auth fails because the SMTP server identifies
+ ;; only the first part of the string (delimited by
+ ;; new line characters) as a response from the
+ ;; client, and the rest as distinct commands.
+
+ ;; In my case, the response string is 80 characters
+ ;; long. Without the no-line-break option for
+ ;; `base64-encode-string', only the first 76 characters
+ ;; are taken as a response to the server, and the
+ ;; authentication fails.
+ (encoded (base64-encode-string response t)))
+ (smtpmail-command-or-throw process encoded)))))
+
+(cl-defmethod smtpmail-try-auth-method
+ (process (_mech (eql login)) user password)
+ (smtpmail-command-or-throw process "AUTH LOGIN")
+ (smtpmail-command-or-throw process (base64-encode-string user t))
+ (smtpmail-command-or-throw process (base64-encode-string password t)))
+
+(cl-defmethod smtpmail-try-auth-method
+ (process (_mech (eql plain)) user password)
+ ;; We used to send an empty initial request, and wait for an
+ ;; empty response, and then send the password, but this
+ ;; violate a SHOULD in RFC 2222 paragraph 5.1. Note that this
+ ;; is not sent if the server did not advertise AUTH PLAIN in
+ ;; the EHLO response. See RFC 2554 for more info.
+ (smtpmail-command-or-throw
+ process
+ (concat "AUTH PLAIN "
+ (base64-encode-string (concat "\0" user "\0" password) t))
+ 235))
(defun smtpmail-response-code (string)
(when string
@@ -664,7 +675,6 @@ Returns an error if the server cannot be contacted."
(and from
(cadr (mail-extract-address-components from))))
(smtpmail-user-mail-address)))
- response-code
process-buffer
result
auth-mechanisms
@@ -681,7 +691,9 @@ Returns an error if the server cannot be contacted."
(setq buffer-undo-list t)
(erase-buffer))
- ;; open the connection to the server
+ ;; Open the connection to the server.
+ ;; FIXME: Should we use raw-text-dos coding system to handle the r\n
+ ;; for us?
(let ((coding-system-for-read 'binary)
(coding-system-for-write 'binary))
(setq result
@@ -718,9 +730,8 @@ Returns an error if the server cannot be contacted."
(throw 'done (format "Connection not allowed: %s" greeting))))
(with-current-buffer process-buffer
- (set-buffer-process-coding-system 'raw-text-unix 'raw-text-unix)
- (make-local-variable 'smtpmail-read-point)
- (setq smtpmail-read-point (point-min))
+ (set-process-coding-system process 'raw-text-unix 'raw-text-unix)
+ (setq-local smtpmail-read-point (point-min))
(let* ((capabilities (plist-get (cdr result) :capabilities))
(code (smtpmail-response-code capabilities)))
@@ -943,8 +954,7 @@ Returns an error if the server cannot be contacted."
(if (and (multibyte-string-p data)
smtpmail-code-conv-from)
- (setq data (string-as-multibyte
- (encode-coding-string data smtpmail-code-conv-from))))
+ (setq data (encode-coding-string data smtpmail-code-conv-from)))
(if smtpmail-debug-info
(insert data "\r\n"))
@@ -990,9 +1000,9 @@ Returns an error if the server cannot be contacted."
;; RESENT-* fields should stop processing of regular fields.
(save-excursion
(setq addr-regexp
- (if (re-search-forward "^Resent-\\(to\\|cc\\|bcc\\):"
+ (if (re-search-forward "^Resent-\\(To\\|Cc\\|Bcc\\):"
header-end t)
- "^Resent-\\(to\\|cc\\|bcc\\):"
+ "^Resent-\\(To\\|Cc\\|Bcc\\):"
"^\\(To:\\|Cc:\\|Bcc:\\)")))
(while (re-search-forward addr-regexp header-end t)
@@ -1025,14 +1035,14 @@ Returns an error if the server cannot be contacted."
(setq smtpmail-recipient-address-list recipient-address-list))))))
(defun smtpmail-do-bcc (header-end)
- "Delete [Resent-]BCC: and their continuation lines from the header area.
-There may be multiple BCC: lines, and each may have arbitrarily
+ "Delete [Resent-]Bcc: and their continuation lines from the header area.
+There may be multiple Bcc: lines, and each may have arbitrarily
many continuation lines."
(let ((case-fold-search t))
(save-excursion
(goto-char (point-min))
- ;; iterate over all BCC: lines
- (while (re-search-forward "^\\(RESENT-\\)?BCC:" header-end t)
+ ;; iterate over all Bcc: lines
+ (while (re-search-forward "^\\(RESENT-\\)?Bcc:" header-end t)
(delete-region (match-beginning 0)
(progn (forward-line 1) (point)))
;; get rid of any continuation lines
diff --git a/lisp/mail/supercite.el b/lisp/mail/supercite.el
index 4809c33abc4..ce00a7cf665 100644
--- a/lisp/mail/supercite.el
+++ b/lisp/mail/supercite.el
@@ -634,12 +634,7 @@ the list should be unique."
(deallocate-event event))
(setq quit-flag nil)
(signal 'quit '())))
- (let ((char
- (if (featurep 'xemacs)
- (let* ((key (and (key-press-event-p event) (event-key event)))
- (char (and key (event-to-character event))))
- char)
- event))
+ (let ((char event)
elt)
(if char (setq char (downcase char)))
(cond
@@ -651,9 +646,7 @@ the list should be unique."
nil)
(t
(message "%s%s" p (single-key-description event))
- (if (featurep 'xemacs)
- (ding nil 'y-or-n-p)
- (ding))
+ (ding)
(discard-input)
(if (eq p prompt)
(setq p (concat "Try again. " prompt)))))))
@@ -709,7 +702,11 @@ the list should be unique."
"Regi frame for glomming mail header information.")
(put 'sc-mail-glom-frame 'risky-local-variable t)
-(defvar curline) ; dynamic bondage
+;; This variable is bound dynamically before calling the forms in the
+;; `sc-mail-glom-frame' variable, and is part of the advertised
+;; interface.
+(with-suppressed-warnings ((lexical curline))
+ (defvar curline))
;; regi functions
@@ -1887,8 +1884,7 @@ and `sc-post-hook' is run after the guts of this function."
;; grab point and mark since the region is probably not active when
;; this function gets automatically called. we want point to be a
;; mark so any deleting before point works properly
- (let* ((zmacs-regions nil) ; for XEemacs
- (mark-active t) ; for Emacs
+ (let* ((mark-active t)
(point (point-marker))
(mark (copy-marker (mark-marker))))
diff --git a/lisp/mail/uce.el b/lisp/mail/uce.el
index d0837d90ea1..7225cda6c0e 100644
--- a/lisp/mail/uce.el
+++ b/lisp/mail/uce.el
@@ -338,7 +338,7 @@ You might need to set `uce-mail-reader' before using this."
(if mail-default-headers
(insert mail-default-headers))
(if mail-default-reply-to
- (insert "Reply-to: " mail-default-reply-to "\n"))
+ (insert "Reply-To: " mail-default-reply-to "\n"))
(insert mail-header-separator "\n")
;; Insert all our text. Then go back to the place where we started.
(if to (setq to (point)))
diff --git a/lisp/mail/uudecode.el b/lisp/mail/uudecode.el
index a78202938e4..9ccdceeeb3f 100644
--- a/lisp/mail/uudecode.el
+++ b/lisp/mail/uudecode.el
@@ -1,4 +1,4 @@
-;;; uudecode.el -- elisp native uudecode
+;;; uudecode.el -- elisp native uudecode -*- lexical-binding:t -*-
;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
@@ -24,13 +24,10 @@
;;; Code:
-(eval-when-compile (require 'cl))
-
-(eval-and-compile
- (defalias 'uudecode-char-int
- (if (fboundp 'char-int)
- 'char-int
- 'identity)))
+(defalias 'uudecode-char-int
+ (if (fboundp 'char-int)
+ 'char-int
+ 'identity))
(defgroup uudecode nil
"Decoding of uuencoded data."
@@ -41,19 +38,16 @@
"Non-nil value should be a string that names a uu decoder.
The program should expect to read uu data on its standard
input and write the converted data to its standard output."
- :type 'string
- :group 'uudecode)
+ :type 'string)
(defcustom uudecode-decoder-switches nil
"List of command line flags passed to `uudecode-decoder-program'."
- :group 'uudecode
:type '(repeat string))
(defcustom uudecode-use-external
(executable-find uudecode-decoder-program)
"Use external uudecode program."
:version "22.1"
- :group 'uudecode
:type 'boolean)
(defconst uudecode-alphabet "\040-\140")
@@ -78,7 +72,7 @@ input and write the converted data to its standard output."
If FILE-NAME is non-nil, save the result to FILE-NAME. The program
used is specified by `uudecode-decoder-program'."
(interactive "r\nP")
- (let ((cbuf (current-buffer)) tempfile firstline status)
+ (let ((cbuf (current-buffer)) tempfile firstline)
(save-excursion
(goto-char start)
(when (re-search-forward uudecode-begin-line nil t)
@@ -100,17 +94,13 @@ used is specified by `uudecode-decoder-program'."
(make-temp-name "uu")
uudecode-temporary-file-directory))))
(let ((cdir default-directory)
- (default-process-coding-system
- (if (featurep 'xemacs)
- ;; In XEmacs, nil is not a valid coding system.
- '(binary . binary)
- nil)))
+ (default-process-coding-system nil))
(unwind-protect
(with-temp-buffer
(insert "begin 600 " (file-name-nondirectory tempfile) "\n")
(insert-buffer-substring cbuf firstline end)
(cd (file-name-directory tempfile))
- (apply 'call-process-region
+ (apply #'call-process-region
(point-min)
(point-max)
uudecode-decoder-program
@@ -128,20 +118,6 @@ used is specified by `uudecode-decoder-program'."
(message "Can not uudecode")))
(ignore-errors (or file-name (delete-file tempfile))))))
-(eval-and-compile
- (defalias 'uudecode-string-to-multibyte
- (cond
- ((featurep 'xemacs)
- 'identity)
- ((fboundp 'string-to-multibyte)
- 'string-to-multibyte)
- (t
- (lambda (string)
- "Return a multibyte string with the same individual chars as string."
- (mapconcat
- (lambda (ch) (string-as-multibyte (char-to-string ch)))
- string ""))))))
-
;;;###autoload
(defun uudecode-decode-region-internal (start end &optional file-name)
"Uudecode region between START and END without using an external program.
@@ -188,12 +164,12 @@ If FILE-NAME is non-nil, save the result to FILE-NAME."
(cond ((= counter 4)
(setq result (cons
(concat
- (char-to-string (lsh bits -16))
- (char-to-string (logand (lsh bits -8) 255))
+ (char-to-string (ash bits -16))
+ (char-to-string (logand (ash bits -8) 255))
(char-to-string (logand bits 255)))
result))
(setq bits 0 counter 0))
- (t (setq bits (lsh bits 6)))))))
+ (t (setq bits (ash bits 6)))))))
(cond
(done)
((> 0 remain)
@@ -205,24 +181,24 @@ If FILE-NAME is non-nil, save the result to FILE-NAME."
((= counter 3)
(setq result (cons
(concat
- (char-to-string (logand (lsh bits -16) 255))
- (char-to-string (logand (lsh bits -8) 255)))
+ (char-to-string (logand (ash bits -16) 255))
+ (char-to-string (logand (ash bits -8) 255)))
result)))
((= counter 2)
(setq result (cons
- (char-to-string (logand (lsh bits -10) 255))
+ (char-to-string (logand (ash bits -10) 255))
result))))
(skip-chars-forward non-data-chars end))
(if file-name
(with-temp-file file-name
- (unless (featurep 'xemacs) (set-buffer-multibyte nil))
- (insert (apply 'concat (nreverse result))))
+ (set-buffer-multibyte nil)
+ (insert (apply #'concat (nreverse result))))
(or (markerp end) (setq end (set-marker (make-marker) end)))
(goto-char start)
(if enable-multibyte-characters
(dolist (x (nreverse result))
- (insert (uudecode-string-to-multibyte x)))
- (insert (apply 'concat (nreverse result))))
+ (insert (decode-coding-string x 'binary)))
+ (insert (apply #'concat (nreverse result))))
(delete-region (point) end))))))
;;;###autoload
diff --git a/lisp/mail/yenc.el b/lisp/mail/yenc.el
index f7a12d6c9e2..75b62c14117 100644
--- a/lisp/mail/yenc.el
+++ b/lisp/mail/yenc.el
@@ -1,4 +1,4 @@
-;;; yenc.el --- elisp native yenc decoder
+;;; yenc.el --- elisp native yenc decoder -*- lexical-binding:t -*-
;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
@@ -32,7 +32,7 @@
;;; Code:
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl-lib))
(defconst yenc-begin-line
"^=ybegin.*$")
@@ -97,14 +97,14 @@
(cond ((or (eq char ?\r)
(eq char ?\n)))
((eq char ?=)
- (setq char (char-after (incf first)))
+ (setq char (char-after (cl-incf first)))
(with-current-buffer work-buffer
(insert-char (mod (- char 106) 256) 1)))
(t
(with-current-buffer work-buffer
;;(insert-char (mod (- char 42) 256) 1)
(insert-char (aref yenc-decoding-vector char) 1))))
- (incf first))
+ (cl-incf first))
(setq bytes (buffer-size work-buffer))
(unless (and (= (cdr (assq 'size header-alist)) bytes)
(= (cdr (assq 'size footer-alist)) bytes))