branch: externals/hyperbole
commit bbe2eaab294bc5357e6198bb5fbbfbf67e8fca20
Merge: 29902906f4 f13dab2e88
Author: Robert Weiner <[email protected]>
Commit: Robert Weiner <[email protected]>

    Merge branch 'master' of hyperbole
---
 ChangeLog           | 10 ++++++++++
 hsmail.el           | 55 ++++++++++++++++-------------------------------------
 test/hpath-tests.el | 38 ++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 39 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 832fe568b5..d4275e146c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,16 @@
     multi-variable paths like:  "${load-path}/../hyperbole/$DOT/hypb.el")
     where DOT = ".".
 
+2022-01-06  Mats Lidell  <[email protected]>
+
+* hsmail.el: Cleanup patch from Stefan Monnier. Thank you Stefan.
+
+* test/hpath-tests.el (hpath:auto-variable-alist-load-path-test)
+    (hpath:auto-variable-alist-org-folder-test)
+    (hpath:auto-variable-alist-pythonpath-test): Add tests for
+    hpath:auto-variable-alist patterns.
+    (hpath-tests--insert): Add test helper.
+
 2022-01-02  Bob Weiner  <[email protected]>
 
 * test/hpath-tests.el (hpath:should-exist-paths, hpath:should-not-exist-paths):
diff --git a/hsmail.el b/hsmail.el
index eeed0b1b17..a035ca7e5b 100644
--- a/hsmail.el
+++ b/hsmail.el
@@ -4,7 +4,7 @@
 ;;
 ;; Orig-Date:     9-May-91 at 04:50:20
 ;;
-;; Copyright (C) 1991-2016  Free Software Foundation, Inc.
+;; Copyright (C) 1991-2022  Free Software Foundation, Inc.
 ;; See the "HY-COPY" file for license information.
 ;;
 ;; This file is part of GNU Hyperbole.
@@ -17,6 +17,9 @@
 ;;; ************************************************************************
 
 (require 'sendmail)
+(require 'hypb)                         ;For `hypb:supercite-p'.
+
+(defvar inhibit-hyperbole-messaging) ;; From "hsettings.el".
 
 ;;; ************************************************************************
 ;;; Public variables
@@ -24,43 +27,16 @@
 
 (defvar smail:comment nil
   "Default comment form to evaluate and add to outgoing mail and Gnus postings.
-Default is nil for no comment.  Set to: '(format \"Comments: GNU Hyperbole 
mail buttons accepted, v%s.\n\" hyperb:version)
+Default is nil for no comment.  Set to:
+
+    (format \"Comments: GNU Hyperbole mail buttons accepted, v%s.\n\"
+                hyperb:version)
+
 for a comment.")
 
-;;; Used by 'mail-send' in Emacs "sendmail.el".
-(if (boundp 'send-mail-function)
-    (or (if (listp send-mail-function)
-           (unless (equal (nth 2 send-mail-function) '(smail:widen))
-             (error
-              "(hsmail): Set 'send-mail-function' to a symbol-name, not a 
list, before load")))
-       (setq send-mail-function `(lambda () (smail:widen) 
(,send-mail-function))))
-  (error "(hsmail): Install an Emacs \"sendmail.el\" which includes 
'send-mail-function'"))
-
-(if (fboundp 'mail-prefix-region)
-    ;;
-    ;; For compatibility with rsw-modified sendmail.el.
-    (defvar mail-yank-hook
-      ;; Set off original message.
-      (lambda () (mail-prefix-region (mark t) (point)))
-      "*Hook to run mail yank preface function.
-Expects point and mark to be set to the region to preface.")
-  ;;
-  ;; Else for compatibility with Supercite and GNU Emacs.
-  ;; If you create your own yank hook, set this variable rather than
-  ;; `mail-yank-hook' from above.
-  (defvar mail-citation-hook nil
-    "Hook for modifying a citation just inserted in the mail buffer.
-Each hook function can find the citation between (point) and (mark t),
-and should leave point and mark around the citation text as modified.
-The hook functions can find the header of the cited message
-in the variable `mail-citation-header', whether or not this is included
-in the cited portion of the message.
-
-If this hook is entirely empty (nil), a default action is taken
-instead of no action.")
-  (defvar mail-yank-hooks '(mail-indent-citation)
-      "*Obsolete hook to run mail yank citation function.  Use 
mail-citation-hook instead.
-Expects point and mark to be set to the region to cite."))
+;; Used by 'mail-send' in Emacs "sendmail.el".
+;; FIXME: Is this still needed?
+(add-function :before send-mail-function #'smail:widen)
 
 ;; For compatibility with Supercite and GNU Emacs.
 (defvar mail-yank-prefix "> "
@@ -81,16 +57,17 @@ Used by `mail-yank-original' via `mail-indent-citation'.")
 ;;; ************************************************************************
 
 (defun smail:comment-add (&optional comment-form)
-  "Add a comment to the current outgoing message if Hyperbole has been loaded 
and `inhibit-hyperbole-messaging' is nil.
+  "Add a comment to the current outgoing message.
+Only if Hyperbole has been loaded and `inhibit-hyperbole-messaging' is nil.
 Optional COMMENT-FORM is evaluated to obtain the string to add to the
 message.  If not given, 'smail:comment' is evaluated by default."
   (if (and (featurep 'hyperbole) (not inhibit-hyperbole-messaging))
-      (let ((comment (eval (or comment-form smail:comment))))
+      (let ((comment (eval (or comment-form smail:comment) t)))
        (if comment
            (save-excursion
              (goto-char (point-min))
              (and (or (search-forward mail-header-separator nil t)
-                      (if (eq major-mode 'mh-letter-mode)
+                      (if (derived-mode-p 'mh-letter-mode)
                           (search-forward "\n--------" nil t)))
                   (not (search-backward comment nil t))
                   (progn (beginning-of-line) (insert comment))))))))
diff --git a/test/hpath-tests.el b/test/hpath-tests.el
index f75cf633e1..febd8bda11 100644
--- a/test/hpath-tests.el
+++ b/test/hpath-tests.el
@@ -213,5 +213,43 @@
             (hy-test-helpers:action-key-should-call-hpath:find 
(expand-file-name file hyperb:dir))))
       (kill-buffer shell-buffer))))
 
+(defun hpath-tests--insert (str &optional with-quotes)
+  "Insert STR with quotes if WITH-QUOTES is not nil."
+  (concat (when with-quotes "\"") str (when with-quotes "\"")))
+
+(ert-deftest hpath:auto-variable-alist-load-path-test ()
+  "An elisp file should be looked up in the load path."
+  (let ((load-path (list hyperb:dir))
+        (el-file "hyperbole.el"))
+    (dolist (with-quotes '(nil t))
+      (with-temp-buffer
+        (insert (hpath-tests--insert el-file with-quotes))
+        (goto-char 4)
+        (hy-test-helpers:action-key-should-call-hpath:find (expand-file-name 
el-file hyperb:dir))))))
+
+(ert-deftest hpath:auto-variable-alist-org-folder-test ()
+  "An org file should be looked up in the org directory."
+  (let ((org-directory (expand-file-name "HY-TALK" hyperb:dir))
+        (org-file "HY-TALK.org"))
+    (dolist (with-quotes '(nil t))
+      (with-temp-buffer
+        (insert (hpath-tests--insert org-file with-quotes))
+        (goto-char 4)
+        (hy-test-helpers:action-key-should-call-hpath:find (expand-file-name 
org-file org-directory))))))
+
+(ert-deftest hpath:auto-variable-alist-pythonpath-test ()
+  "A python file should be looked up in the PYTHONPATH."
+  (let ((py-file "topwin.py")
+        (old-python-path (getenv "PYTHONPATH")))
+    (unwind-protect
+        (progn
+          (setenv "PYTHONPATH" hyperb:dir)
+          (dolist (with-quotes '(nil t))
+            (with-temp-buffer
+              (insert (hpath-tests--insert py-file with-quotes))
+              (goto-char 4)
+              (hy-test-helpers:action-key-should-call-hpath:find 
(expand-file-name py-file hyperb:dir)))))
+      (setenv "PYTHONPATH" old-python-path))))
+
 (provide 'hpath-tests)
 ;;; hpath-tests.el ends here

Reply via email to