diff options
| author | Basil L. Contovounesios | 2020-05-29 19:56:14 +0100 |
|---|---|---|
| committer | Basil L. Contovounesios | 2020-06-18 12:46:21 +0100 |
| commit | 0185d76e7426eb1b58a9b60b0d18e763ddf57dea (patch) | |
| tree | 68e6f560b1751902e98a241a3bf732b9fd596364 /lisp/net | |
| parent | 97d1f672ac1529ac07a999405f630cb19a1010eb (diff) | |
| download | emacs-0185d76e7426eb1b58a9b60b0d18e763ddf57dea.tar.gz emacs-0185d76e7426eb1b58a9b60b0d18e763ddf57dea.zip | |
Fix and extend format-spec (bug#41758)
* lisp/format-spec.el: Use lexical-binding. Remove dependence on
subr-x.el.
(format-spec-make): Clarify docstring.
(format-spec--parse-modifiers): Rename to...
(format-spec--parse-flags): ...this and simplify. In particular,
don't bother parsing :space-pad which is redundant and unused.
(format-spec--pad): Remove, replacing with...
(format-spec--do-flags): ...this new helper function which performs
more of format-spec's supported text manipulation.
(format-spec): Autoload. Allow optional argument to take on special
values 'ignore' and 'delete' for more control over what happens when
a replacement for a format specification isn't provided. Bring back
proper support for a precision modifier similar to that of 'format'.
* lisp/battery.el (battery-format): Rewrite in terms of format-spec.
(battery-echo-area-format, battery-mode-line-format): Mention
support of format-spec syntax in docstrings.
* doc/lispref/strings.texi (Custom Format Strings):
* etc/NEWS: Document and announce these changes.
* lisp/dired-aux.el (dired-do-compress-to):
* lisp/erc/erc-match.el (erc-log-matches):
* lisp/erc/erc.el (erc-update-mode-line-buffer):
* lisp/gnus/gnus-sieve.el (gnus-sieve-update):
* lisp/gnus/gssapi.el (open-gssapi-stream):
* lisp/gnus/mail-source.el (mail-source-fetch-file)
(mail-source-fetch-directory, mail-source-fetch-pop)
(mail-source-fetch-imap):
* lisp/gnus/message.el (message-insert-formatted-citation-line):
* lisp/image-dired.el:
* lisp/net/eww.el:
* lisp/net/imap.el (imap-kerberos4-open, imap-gssapi-open)
(imap-shell-open):
* lisp/net/network-stream.el (network-stream-open-shell):
* lisp/obsolete/tls.el (open-tls-stream):
* lisp/textmodes/tex-mode.el:
Remove extraneous loads and autoloads of format-spec now that it is
autoloaded and simplify its uses where possible.
* test/lisp/battery-tests.el (battery-format): Test new format-spec
support.
* test/lisp/format-spec-tests.el (test-format-spec): Rename to...
(format-spec) ...this, extending test cases.
(test-format-unknown): Rename to...
(format-spec-unknown): ...this, extending test cases.
(test-format-modifiers): Rename to...
(format-spec-flags): ...this.
(format-spec-make, format-spec-parse-flags, format-spec-do-flags)
(format-spec-do-flags-truncate, format-spec-do-flags-pad)
(format-spec-do-flags-chop, format-spec-do-flags-case): New tests.
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/eww.el | 1 | ||||
| -rw-r--r-- | lisp/net/imap.el | 30 | ||||
| -rw-r--r-- | lisp/net/network-stream.el | 13 |
3 files changed, 14 insertions, 30 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 2a70560ca7b..cf31d37f072 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -25,7 +25,6 @@ | |||
| 25 | ;;; Code: | 25 | ;;; Code: |
| 26 | 26 | ||
| 27 | (require 'cl-lib) | 27 | (require 'cl-lib) |
| 28 | (require 'format-spec) | ||
| 29 | (require 'shr) | 28 | (require 'shr) |
| 30 | (require 'url) | 29 | (require 'url) |
| 31 | (require 'url-queue) | 30 | (require 'url-queue) |
diff --git a/lisp/net/imap.el b/lisp/net/imap.el index aa10f0291fd..a492dc8c798 100644 --- a/lisp/net/imap.el +++ b/lisp/net/imap.el | |||
| @@ -136,7 +136,6 @@ | |||
| 136 | ;;; Code: | 136 | ;;; Code: |
| 137 | 137 | ||
| 138 | (eval-when-compile (require 'cl-lib)) | 138 | (eval-when-compile (require 'cl-lib)) |
| 139 | (require 'format-spec) | ||
| 140 | (require 'utf7) | 139 | (require 'utf7) |
| 141 | (require 'rfc2104) | 140 | (require 'rfc2104) |
| 142 | ;; Hmm... digest-md5 is not part of Emacs. | 141 | ;; Hmm... digest-md5 is not part of Emacs. |
| @@ -517,12 +516,9 @@ sure of changing the value of `foo'." | |||
| 517 | (process-connection-type imap-process-connection-type) | 516 | (process-connection-type imap-process-connection-type) |
| 518 | (process (start-process | 517 | (process (start-process |
| 519 | name buffer shell-file-name shell-command-switch | 518 | name buffer shell-file-name shell-command-switch |
| 520 | (format-spec | 519 | (format-spec cmd `((?s . ,server) |
| 521 | cmd | 520 | (?p . ,(number-to-string port)) |
| 522 | (format-spec-make | 521 | (?l . ,imap-default-user))))) |
| 523 | ?s server | ||
| 524 | ?p (number-to-string port) | ||
| 525 | ?l imap-default-user)))) | ||
| 526 | response) | 522 | response) |
| 527 | (when process | 523 | (when process |
| 528 | (with-current-buffer buffer | 524 | (with-current-buffer buffer |
| @@ -583,12 +579,9 @@ sure of changing the value of `foo'." | |||
| 583 | (process-connection-type imap-process-connection-type) | 579 | (process-connection-type imap-process-connection-type) |
| 584 | (process (start-process | 580 | (process (start-process |
| 585 | name buffer shell-file-name shell-command-switch | 581 | name buffer shell-file-name shell-command-switch |
| 586 | (format-spec | 582 | (format-spec cmd `((?s . ,server) |
| 587 | cmd | 583 | (?p . ,(number-to-string port)) |
| 588 | (format-spec-make | 584 | (?l . ,imap-default-user))))) |
| 589 | ?s server | ||
| 590 | ?p (number-to-string port) | ||
| 591 | ?l imap-default-user)))) | ||
| 592 | response) | 585 | response) |
| 593 | (when process | 586 | (when process |
| 594 | (with-current-buffer buffer | 587 | (with-current-buffer buffer |
| @@ -701,13 +694,10 @@ sure of changing the value of `foo'." | |||
| 701 | (process-connection-type imap-process-connection-type) | 694 | (process-connection-type imap-process-connection-type) |
| 702 | (process (start-process | 695 | (process (start-process |
| 703 | name buffer shell-file-name shell-command-switch | 696 | name buffer shell-file-name shell-command-switch |
| 704 | (format-spec | 697 | (format-spec cmd `((?s . ,server) |
| 705 | cmd | 698 | (?g . ,imap-shell-host) |
| 706 | (format-spec-make | 699 | (?p . ,(number-to-string port)) |
| 707 | ?s server | 700 | (?l . ,imap-default-user)))))) |
| 708 | ?g imap-shell-host | ||
| 709 | ?p (number-to-string port) | ||
| 710 | ?l imap-default-user))))) | ||
| 711 | (when process | 701 | (when process |
| 712 | (while (and (memq (process-status process) '(open run)) | 702 | (while (and (memq (process-status process) '(open run)) |
| 713 | (set-buffer buffer) ;; XXX "blue moon" nntp.el bug | 703 | (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el index 1d5cf382a84..1c371f59870 100644 --- a/lisp/net/network-stream.el +++ b/lisp/net/network-stream.el | |||
| @@ -170,8 +170,8 @@ a greeting from the server. | |||
| 170 | :nowait, if non-nil, says the connection should be made | 170 | :nowait, if non-nil, says the connection should be made |
| 171 | asynchronously, if possible. | 171 | asynchronously, if possible. |
| 172 | 172 | ||
| 173 | :shell-command is a format-spec string that can be used if :type | 173 | :shell-command is a `format-spec' string that can be used if |
| 174 | is `shell'. It has two specs, %s for host and %p for port | 174 | :type is `shell'. It has two specs, %s for host and %p for port |
| 175 | number. Example: \"ssh gateway nc %s %p\". | 175 | number. Example: \"ssh gateway nc %s %p\". |
| 176 | 176 | ||
| 177 | :tls-parameters is a list that should be supplied if you're | 177 | :tls-parameters is a list that should be supplied if you're |
| @@ -453,11 +453,7 @@ gnutls-boot (as returned by `gnutls-boot-parameters')." | |||
| 453 | (network-stream-command stream capability-command eo-capa) | 453 | (network-stream-command stream capability-command eo-capa) |
| 454 | 'tls))))))) | 454 | 'tls))))))) |
| 455 | 455 | ||
| 456 | (declare-function format-spec "format-spec" (format spec)) | ||
| 457 | (declare-function format-spec-make "format-spec" (&rest pairs)) | ||
| 458 | |||
| 459 | (defun network-stream-open-shell (name buffer host service parameters) | 456 | (defun network-stream-open-shell (name buffer host service parameters) |
| 460 | (require 'format-spec) | ||
| 461 | (let* ((capability-command (plist-get parameters :capability-command)) | 457 | (let* ((capability-command (plist-get parameters :capability-command)) |
| 462 | (eoc (plist-get parameters :end-of-command)) | 458 | (eoc (plist-get parameters :end-of-command)) |
| 463 | (start (with-current-buffer buffer (point))) | 459 | (start (with-current-buffer buffer (point))) |
| @@ -467,9 +463,8 @@ gnutls-boot (as returned by `gnutls-boot-parameters')." | |||
| 467 | shell-command-switch | 463 | shell-command-switch |
| 468 | (format-spec | 464 | (format-spec |
| 469 | (plist-get parameters :shell-command) | 465 | (plist-get parameters :shell-command) |
| 470 | (format-spec-make | 466 | `((?s . ,host) |
| 471 | ?s host | 467 | (?p . ,service))))))) |
| 472 | ?p service)))))) | ||
| 473 | (when coding (if (consp coding) | 468 | (when coding (if (consp coding) |
| 474 | (set-process-coding-system stream | 469 | (set-process-coding-system stream |
| 475 | (car coding) | 470 | (car coding) |