|
3 | 3 | ;; Author: Bob Weiner |
4 | 4 | ;; |
5 | 5 | ;; Orig-Date: 1-Nov-91 at 00:44:23 |
6 | | -;; Last-Mod: 16-Nov-25 at 10:49:44 by Bob Weiner |
| 6 | +;; Last-Mod: 23-Nov-25 at 12:54:16 by Bob Weiner |
7 | 7 | ;; |
8 | 8 | ;; SPDX-License-Identifier: GPL-3.0-or-later |
9 | 9 | ;; |
@@ -682,7 +682,7 @@ use with `string-match'.") |
682 | 682 | ;;; Private variables |
683 | 683 | ;;; ************************************************************************ |
684 | 684 |
|
685 | | -(defconst hpath:html-anchor-id-pattern "\\(id\\|name\\)=['\"]%s['\"]?" |
| 685 | +(defconst hpath:html-anchor-id-pattern "\\(id\\|name\\)=['\"]%s['\"]" |
686 | 686 | "Regexp matching an html anchor id definition. |
687 | 687 | Contains a %s for replacement of a specific anchor id.") |
688 | 688 |
|
@@ -2081,29 +2081,31 @@ prior to calling this function." |
2081 | 2081 | var-group))) |
2082 | 2082 |
|
2083 | 2083 | (defun hpath:shorten (path &optional relative-to) |
2084 | | - "Shorten and return a PATH optionally RELATIVE-TO other path. |
2085 | | -If RELATIVE-TO is omitted or nil, set it to `default-directory'. |
2086 | | -Replace Emacs Lisp variables and environment variables (format of |
2087 | | -${var}) with their values in PATH. The first matching value for |
2088 | | -variables like `${PATH}' is used. Then abbreviate any remaining |
2089 | | -path." |
| 2084 | + "Expand and then shorten and return a PATH optionally RELATIVE-TO other path. |
| 2085 | +Ignore optional RELATIVE-TO if editing a message, |
| 2086 | +i.e. (hmail:editor-p) => t. If RELATIVE-TO is omitted or nil, |
| 2087 | +set it to `default-directory'. Replace Emacs Lisp variables and |
| 2088 | +environment variables (format of ${var}) with their values in |
| 2089 | +PATH. The first matching value for variables like `${PATH}' is |
| 2090 | +used. Then abbreviate any remaining path." |
2090 | 2091 | (setq path (expand-file-name (hpath:substitute-value path))) |
2091 | 2092 | (when (file-directory-p path) |
2092 | 2093 | ;; Force path to have a final directory separator so comparisons |
2093 | 2094 | ;; to `default-directory' work |
2094 | 2095 | (setq path (file-name-as-directory path))) |
2095 | | - (unless relative-to |
2096 | | - (setq relative-to default-directory)) |
2097 | | - (when (stringp relative-to) |
2098 | | - (setq relative-to (expand-file-name |
2099 | | - (hpath:substitute-value relative-to)) |
2100 | | - path |
2101 | | - (cond ((string-equal path relative-to) |
2102 | | - "") |
2103 | | - ((string-equal (file-name-directory path) relative-to) |
2104 | | - (file-name-nondirectory path)) |
2105 | | - (t (hpath:relative-to path relative-to))))) |
2106 | | - (hpath:abbreviate-file-name (hpath:substitute-var path))) |
| 2096 | + (unless (hmail:editor-p) |
| 2097 | + (unless relative-to |
| 2098 | + (setq relative-to default-directory)) |
| 2099 | + (when (stringp relative-to) |
| 2100 | + (setq relative-to (expand-file-name |
| 2101 | + (hpath:substitute-value relative-to)) |
| 2102 | + path |
| 2103 | + (cond ((string-equal path relative-to) |
| 2104 | + "") |
| 2105 | + ((string-equal (file-name-directory path) relative-to) |
| 2106 | + (file-name-nondirectory path)) |
| 2107 | + (t (hpath:relative-to path relative-to)))))) |
| 2108 | + (hpath:abbreviate-file-name (hpath:substitute-var path))) |
2107 | 2109 |
|
2108 | 2110 | (defun hpath:substitute-value (path) |
2109 | 2111 | "Substitute values for Emacs Lisp variables and environment variables in PATH. |
|
0 commit comments