commit d9e10a1d1a56b8740a276a3fa418f628f79790d0 (HEAD, refs/remotes/origin/master) Author: Michael Albinus Date: Wed May 6 10:36:43 2020 +0200 process-file in Tramp must return exit code (Bug#41099) * lisp/net/tramp-adb.el (tramp-adb-send-command-and-check): Add optional argument EXIT-STATUS. (tramp-adb-handle-process-file): Use it. * lisp/net/tramp-sh.el (tramp-send-command-and-check): Add optional argument EXIT-STATUS. (tramp-sh-handle-process-file): Use it. (Bug#41099) * test/lisp/net/tramp-tests.el (tramp-test28-process-file): Adapt test. diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index aae25d1dbf..7f829f1520 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -896,14 +896,13 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." ;; it. Call it in a subshell, in order to preserve working ;; directory. (condition-case nil - (progn - (setq ret - (if (tramp-adb-send-command-and-check - v - (format "(cd %s; %s)" - (tramp-shell-quote-argument localname) command)) - ;; Set return status accordingly. - 0 1)) + (unwind-protect + (setq ret (tramp-adb-send-command-and-check + v (format + "(cd %s; %s)" + (tramp-shell-quote-argument localname) command) + t)) + (unless (natnump ret) (setq ret 1)) ;; We should add the output anyway. (when outbuf (with-current-buffer outbuf @@ -1186,11 +1185,14 @@ This happens for Android >= 4.0." (while (re-search-forward "\r+$" nil t) (replace-match "" nil nil)))))) -(defun tramp-adb-send-command-and-check (vec command) +(defun tramp-adb-send-command-and-check (vec command &optional exit-status) "Run COMMAND and check its exit status. Sends `echo $?' along with the COMMAND for checking the exit status. If COMMAND is nil, just sends `echo $?'. Returns nil if -the exit status is not equal 0, and t otherwise." +the exit status is not equal 0, and t otherwise. + +Optional argument EXIT-STATUS, if non-nil, triggers the return of +the exit status." (tramp-adb-send-command vec (if command (format "%s; echo tramp_exit_status $?" command) @@ -1201,7 +1203,9 @@ the exit status is not equal 0, and t otherwise." vec 'file-error "Couldn't find exit status of `%s'" command)) (skip-chars-forward "^ ") (prog1 - (zerop (read (current-buffer))) + (if exit-status + (read (current-buffer)) + (zerop (read (current-buffer)))) (let ((inhibit-read-only t)) (delete-region (match-beginning 0) (point-max)))))) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 592dcf6715..c6eb7a8ff4 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -3136,13 +3136,12 @@ STDERR can also be a file name." ;; directory. (condition-case nil (unwind-protect - (setq ret - (if (tramp-send-command-and-check - v (format "cd %s && %s" - (tramp-shell-quote-argument localname) - command) - t t) - 0 1)) + (setq ret (tramp-send-command-and-check + v (format + "cd %s && %s" + (tramp-shell-quote-argument localname) command) + t t t)) + (unless (natnump ret) (setq ret 1)) ;; We should add the output anyway. (when outbuf (with-current-buffer outbuf @@ -5239,7 +5238,7 @@ function waits for output unless NOOUTPUT is set." found))) (defun tramp-send-command-and-check - (vec command &optional subshell dont-suppress-err) + (vec command &optional subshell dont-suppress-err exit-status) "Run COMMAND and check its exit status. Send `echo $?' along with the COMMAND for checking the exit status. If COMMAND is nil, just send `echo $?'. Return t if the exit @@ -5247,7 +5246,9 @@ status is 0, and nil otherwise. If the optional argument SUBSHELL is non-nil, the command is executed in a subshell, ie surrounded by parentheses. If -DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to /dev/null." +DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to /dev/null. +Optional argument EXIT-STATUS, if non-nil, triggers the return of +the exit status." (tramp-send-command vec (concat (if subshell "( " "") @@ -5261,7 +5262,9 @@ DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to /dev/null." vec 'file-error "Couldn't find exit status of `%s'" command)) (skip-chars-forward "^ ") (prog1 - (zerop (read (current-buffer))) + (if exit-status + (read (current-buffer)) + (zerop (read (current-buffer)))) (let ((inhibit-read-only t)) (delete-region (match-beginning 0) (point-max)))))) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 28d20e39f8..462539a7c1 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4208,6 +4208,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (should (zerop (process-file "true"))) (should-not (zerop (process-file "false"))) (should-not (zerop (process-file "binary-does-not-exist"))) + (should (= 42 (process-file "sh" nil nil nil "-c" "exit 42"))) (with-temp-buffer (write-region "foo" nil tmp-name) (should (file-exists-p tmp-name)) commit c4adfbae24d920f0ce62cb88b988219348d1ec73 Author: Tassilo Horn Date: Mon May 4 11:24:08 2020 +0200 Allow for custom URL handlers in browse-url. * lisp/net/browse-url.el (browse-url-handlers): New defcustom. (browse-url-default-handlers): New defvar. (browse-url): Use them. Adapt docstring. Issue a warning pointing to browse-url-handlers when browse-url-browser-function is an alist. (browse-url--mailto, browse-url--man): New functions. (browse-url--browser-defcustom-type): Add :doc that the alist usage is deprecated. (browse-url-browser-function): Remove documentation referring to the alist usage and mention browse-url-handlers. * doc/emacs/misc.texi: Document browse-url-handlers in Browse-URL node. * etc/NEWS: Mention browse-url-default-handlers and browse-url-handlers. diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index 47f195d0b2..d1854f31ff 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi @@ -2920,9 +2920,16 @@ you might like to bind to keys, such as @code{browse-url-at-point} and You can customize Browse-URL's behavior via various options in the @code{browse-url} Customize group. In particular, the option @code{browse-url-mailto-function} lets you define how to follow -@samp{mailto:} URLs, while @code{browse-url-browser-function} lets you -define how to follow other types of URLs. For more information, view -the package commentary by typing @kbd{C-h P browse-url @key{RET}}. +@samp{mailto:} URLs, while @code{browse-url-browser-function} +specifies your default browser. + +@vindex browse-url-handlers + You can define that certain URLs are browsed with other functions by +customizing @code{browse-url-handlers}, an alist of regular +expressions paired with functions to browse matching URLs. + +For more information, view the package commentary by typing @kbd{C-h P +browse-url @key{RET}}. @node Goto Address mode @subsection Activating URLs diff --git a/etc/NEWS b/etc/NEWS index 0f4b6244c6..ac93a76ff9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -304,6 +304,22 @@ use ‘doxygen’ by default one might evaluate: (c++-mode . doxygen))) or use it in a custom ‘c-style’. + +** browse-url + +*** Added support for custom URL handlers + +There is a new defvar 'browse-url-default-handlers' and a defcustom +'browse-url-handlers' being alists with (REGEXP . FUNCTION) entries +allowing to define different browsing FUNCTIONs depending on the URL +to be browsed. The defvar is for default handlers provided by Emacs +itself or external packages, the defcustom is for the user (and allows +for overriding the default handlers). + +Formerly, one could do the same by setting +'browse-url-browser-function' to such an alist. This usage is still +supported but deprecated. + * New Modes and Packages in Emacs 28.1 diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 7aad44b287..1275c15578 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -114,9 +114,10 @@ ;; To always save modified buffers before displaying the file in a browser: ;; (setq browse-url-save-file t) -;; To invoke different browsers for different URLs: -;; (setq browse-url-browser-function '(("^mailto:" . browse-url-mail) -;; ("." . browse-url-firefox))) +;; To invoke different browsers/tools for different URLs, customize +;; `browse-url-handlers'. In earlier versions of Emacs, the same +;; could be done by setting `browse-url-browser-function' to an alist +;; but this usage is deprecated now. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Code: @@ -157,7 +158,9 @@ :value browse-url-default-browser) (function :tag "Your own function") (alist :tag "Regexp/function association list" - :key-type regexp :value-type function))) + :key-type regexp :value-type function + :format "%{%t%}\n%d%v\n" + :doc "Deprecated. Use `browse-url-handlers' instead."))) ;;;###autoload (defcustom browse-url-browser-function 'browse-url-default-browser @@ -165,13 +168,8 @@ This is used by the `browse-url-at-point', `browse-url-at-mouse', and `browse-url-of-file' commands. -If the value is not a function it should be a list of pairs -\(REGEXP . FUNCTION). In this case the function called will be the one -associated with the first REGEXP which matches the current URL. The -function is passed the URL and any other args of `browse-url'. The last -regexp should probably be \".\" to specify a default browser. - -Also see `browse-url-secondary-browser-function'." +Also see `browse-url-secondary-browser-function' and +`browse-url-handlers'." :type browse-url--browser-defcustom-type :version "24.1") @@ -595,6 +593,41 @@ down (this *won't* always work)." "Wrapper command prepended to the Elinks command-line." :type '(repeat (string :tag "Wrapper"))) +(defun browse-url--mailto (url &rest args) + "Calls `browse-url-mailto-function' with URL and ARGS." + (funcall browse-url-mailto-function url args)) + +(defun browse-url--man (url &rest args) + "Calls `browse-url-man-function' with URL and ARGS." + (funcall browse-url-man-function url args)) + +;;;###autoload +(defvar browse-url-default-handlers + '(("\\`mailto:" . browse-url--mailto) + ("\\`man:" . browse-url--man) + ("\\`file://" . browse-url-emacs)) + "Like `browse-url-handlers' but populated by Emacs and packages. + +Emacs and external packages capable of browsing certain URLs +should place their entries in this alist rather than +`browse-url-handlers' which is reserved for the user.") + +(defcustom browse-url-handlers nil + "An alist with elements of the form (REGEXP HANDLER). +Each REGEXP is matched against the URL to be opened in turn and +the first match's HANDLER is invoked with the URL. + +A HANDLER must be a function with the same arguments as +`browse-url'. + +If no REGEXP matches, the same procedure is performed with the +value of `browse-url-default-handlers'. If there is also no +match, the URL is opened using the value of +`browse-url-browser-function'." + :type '(alist :key-type (regexp :tag "Regexp") + :value-type (function :tag "Handler")) + :version "28.1") + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; URL encoding @@ -768,16 +801,18 @@ narrowed." "Ask a WWW browser to load URL. Prompt for a URL, defaulting to the URL at or before point. Invokes a suitable browser function which does the actual job. -The variable `browse-url-browser-function' says which browser function to -use. If the URL is a mailto: URL, consult `browse-url-mailto-function' -first, if that exists. - -The additional ARGS are passed to the browser function. See the doc -strings of the actual functions, starting with `browse-url-browser-function', -for information about the significance of ARGS (most of the functions -ignore it). -If ARGS are omitted, the default is to pass `browse-url-new-window-flag' -as ARGS." + +The variables `browse-url-browser-function', +`browse-url-handlers', and `browse-url-default-handlers' +determine which browser function to use. + +The additional ARGS are passed to the browser function. See the +doc strings of the actual functions, starting with +`browse-url-browser-function', for information about the +significance of ARGS (most of the functions ignore it). + +If ARGS are omitted, the default is to pass +`browse-url-new-window-flag' as ARGS." (interactive (browse-url-interactive-arg "URL: ")) (unless (called-interactively-p 'interactive) (setq args (or args (list browse-url-new-window-flag)))) @@ -786,12 +821,15 @@ as ARGS." (not (string-match "\\`[a-z]+:" url))) (setq url (expand-file-name url))) (let ((process-environment (copy-sequence process-environment)) - (function (or (and (string-match "\\`mailto:" url) - browse-url-mailto-function) - (and (string-match "\\`man:" url) - browse-url-man-function) - browse-url-browser-function)) - ;; Ensure that `default-directory' exists and is readable (b#6077). + (function + (catch 'custom-url-handler + (dolist (regex-handler (append browse-url-handlers + browse-url-default-handlers)) + (when (string-match-p (car regex-handler) url) + (throw 'custom-url-handler (cdr regex-handler)))) + ;; No special handler found. + browse-url-browser-function)) + ;; Ensure that `default-directory' exists and is readable (bug#6077). (default-directory (or (unhandled-file-name-directory default-directory) (expand-file-name "~/")))) ;; When connected to various displays, be careful to use the display of @@ -801,15 +839,19 @@ as ARGS." (setenv "DISPLAY" (frame-parameter nil 'display))) (if (and (consp function) (not (functionp function))) - ;; The `function' can be an alist; look down it for first match - ;; and apply the function (which might be a lambda). - (catch 'done - (dolist (bf function) - (when (string-match (car bf) url) - (apply (cdr bf) url args) - (throw 'done t))) - (error "No browse-url-browser-function matching URL %s" - url)) + ;; The `function' can be an alist; look down it for first + ;; match and apply the function (which might be a lambda). + ;; However, this usage is deprecated as of Emacs 28.1. + (progn + (warn "Having `browse-url-browser-function' set to an +alist is deprecated. Use `browse-url-handlers' instead.") + (catch 'done + (dolist (bf function) + (when (string-match (car bf) url) + (apply (cdr bf) url args) + (throw 'done t))) + (error "No browse-url-browser-function matching URL %s" + url))) ;; Unbound symbols go down this leg, since void-function from ;; apply is clearer than wrong-type-argument from dolist. (apply function url args)))) commit 58c234aa8cb6e76d377f07cbf0b59f2552eb296b Author: Stefan Kangas Date: Wed May 6 03:30:20 2020 +0200 Prefer 'strong' and 'em' to 'b' and 'i' in html-mode * lisp/textmodes/sgml-mode.el (html-face-tag-alist): Prefer inserting 'strong' and 'em' tags to 'b' and 'i' in html-mode. (Bug#41031) * lisp/textmodes/sgml-mode.el (html-mode): Update docstring to do the same. diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 9b29b844d0..b5ff6a6967 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -1852,8 +1852,8 @@ This takes effect when first loading the library.") "Keymap for commands for use in HTML mode.") (defvar html-face-tag-alist - '((bold . "b") - (italic . "i") + '((bold . "strong") + (italic . "em") (underline . "u") (mode-line . "rev")) "Value of `sgml-face-tag-alist' for HTML mode.") @@ -2363,7 +2363,7 @@ have

Very Major Headlines

through
Very Minor Headlines

Paragraphs only need an opening tag. Line breaks and multiple spaces are ignored unless the text is

preformatted.
Text can be marked as -bold, italic or underlined using the normal M-o or +bold, italic or underlined using the normal M-o or Edit/Text Properties/Face commands. Pages can have named points and can link other points commit 8f6524db832f0c6fdbbbc639149fe63065a62096 Author: Paul Eggert Date: Tue May 5 17:16:49 2020 -0700 Don’t assume __has_attribute in emacs-module.c Problem reported by Glenn Morris in: https://lists.gnu.org/r/emacs-devel/2020-05/msg00724.html * src/emacs-module.c: Use HAS_ATTRIBUTE instead of assuming the compiler supports __has_attribute. diff --git a/src/emacs-module.c b/src/emacs-module.c index e43e4907d2..3d1827c7da 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c @@ -248,7 +248,7 @@ module_decode_utf_8 (const char *str, ptrdiff_t len) of `internal_condition_case' etc., and to avoid worrying about passing information to the handler functions. */ -#if !__has_attribute (cleanup) +#if !HAS_ATTRIBUTE (cleanup) #error "__attribute__ ((cleanup)) not supported by this compiler; try GCC" #endif commit bbc34d3762326ea13e9a10a959ea5b59aadb6736 Author: Stefan Monnier Date: Tue May 5 17:53:23 2020 -0400 Try and improve the *Help* layout for things like `diff-refine`. * lisp/help-fns.el (describe-variable-custom-version-info): Follow the usual format of other `help-fns-describe-variable-functions`. diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 0a99b8d6a3..63b066f3b8 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -893,7 +893,7 @@ If ANY-SYMBOL is non-nil, don't insist the symbol be bound." (output nil)) (if custom-version (setq output - (format "This %s was introduced, or its default value was changed, in\nversion %s of Emacs.\n" + (format " This %s was introduced, or its default value was changed, in\n version %s of Emacs.\n" type custom-version)) (when cpv (let* ((package (car-safe cpv)) @@ -904,7 +904,7 @@ If ANY-SYMBOL is non-nil, don't insist the symbol be bound." (emacsv (cdr (assoc version pkg-versions)))) (if (and package version) (setq output - (format (concat "This %s was introduced, or its default value was changed, in\nversion %s of the %s package" + (format (concat " This %s was introduced, or its default value was changed, in\n version %s of the %s package" (if emacsv (format " that is part of Emacs %s" emacsv)) ".\n") @@ -1125,8 +1125,8 @@ it is displayed along with the global value." ;; Note variable's version or package version. (let ((output (describe-variable-custom-version-info variable))) (when output - (terpri) - (terpri) + ;; (terpri) + ;; (terpri) (princ output))))) (add-hook 'help-fns-describe-variable-functions #'help-fns--var-safe-local)