commit c48397a2b30c339cec949c3cada4641b094e0346 (HEAD, refs/remotes/origin/master) Author: Stefan Kangas Date: Tue Aug 16 08:03:22 2022 +0200 Delete implicit XEmacs references from Gnus manual * doc/misc/gnus.texi (Group Buffer Format, Summary Buffer, RSS): Delete some implicit references to XEmacs. (RSS): Fix default value. diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index fd0825bfaa..1cd52d1ed6 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -1803,8 +1803,7 @@ long as Gnus is active. @end menu You can customize the Group Mode tool bar, see @kbd{M-x -customize-apropos @key{RET} gnus-group-tool-bar}. This feature is only -available in Emacs. +customize-apropos @key{RET} gnus-group-tool-bar}. The tool bar icons are now (de)activated correctly depending on the cursor position. Therefore, moving around in the Group Buffer is @@ -4836,8 +4835,7 @@ group buffer (@pxref{Selecting a Group}). You can have as many summary buffers open as you wish. You can customize the Summary Mode tool bar, see @kbd{M-x -customize-apropos @key{RET} gnus-summary-tool-bar}. This feature is only -available in Emacs. +customize-apropos @key{RET} gnus-summary-tool-bar}. @kindex v @r{(Summary)} @cindex keys, reserved for users (Summary) @@ -17341,11 +17339,6 @@ changes to a wiki (e.g., @url{https://cliki.net/site/recent-changes}). @acronym{RSS} has a quite regular and nice interface, and it's possible to get the information Gnus needs to keep groups updated. -Note: you had better use Emacs which supports the @code{utf-8} coding -system because @acronym{RSS} uses UTF-8 for encoding non-@acronym{ASCII} -text by default. It is also used by default for non-@acronym{ASCII} -group names. - @kindex G R @r{(Group)} Use @kbd{G R} from the group buffer to subscribe to a feed---you will be prompted for the location, the title and the description of the feed. @@ -17394,7 +17387,7 @@ The directory where @code{nnrss} stores its files. The default is @vindex nnrss-file-coding-system The coding system used when reading and writing the @code{nnrss} groups data files. The default is the value of -@code{mm-universal-coding-system} (which defaults to @code{emacs-mule}). +@code{mm-universal-coding-system} (which defaults to @code{utf-8-emacs}). @item nnrss-ignore-article-fields @vindex nnrss-ignore-article-fields commit b87400c78b047d242ae188c46c621e0e8a8e69b2 Author: Jim Porter Date: Tue Aug 2 11:40:43 2022 -0700 Make the bookmark fringe icon look like a bookmark * src/fringe.c (large_circle_bits): New variable. (standard_bitmaps): Add large_circle_bits. * lisp/fringe.el (fringe-bitmaps): Add 'large-circle'. (fringe-custom-set-bitmap): New function. * lisp/cus-edit.el (widget-fringe-bitmap-prompt-value-history): New variable. (fringe-bitmap): New widget. * lisp/bookmark.el (bookmark-set-fringe-mark): Obsolete in favor of... (bookmark-fringe-mark): ... this. (bookmark-fringe-mark): Rename this fringe bitmap to... (bookmark-mark): ... and change it to look like a bookmark. (bookmark-face): Don't set the ':background' of the face. Instead, set ':distant-foreground'. (bookmark--set-fringe-mark, bookmark--remove-fringe-mark) (bookmark-store, bookmark--jump-via): Consult the 'bookmark-fringe-mark' option. * doc/lispref/customize.texi (Simple Types): Document 'fringe-bitmap' type. * doc/lispref/display.texi (Fringe Bitmaps): Mention 'large-circle'. * etc/NEWS: Announce this change (bug#56896). diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi index 528421bf3b..6ba35cffff 100644 --- a/doc/lispref/customize.texi +++ b/doc/lispref/customize.texi @@ -672,6 +672,10 @@ The value must be a valid color name. The widget provides completion for color names, as well as a sample and a button for selecting a color name from a list of color names shown in a @file{*Colors*} buffer. + +@item fringe-bitmap +The value must be a valid fringe bitmap name. The widget provides +completion. @end table @node Composite Types diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 96079dc106..d336cda674 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -4626,6 +4626,7 @@ Used to indicate buffer boundaries. Used for different types of fringe cursors. @item @code{exclamation-mark}, @code{question-mark} +@itemx @code{large-circle} Not used by core Emacs features. @end table diff --git a/etc/NEWS b/etc/NEWS index c982684d3a..5d87bc9e2e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2013,6 +2013,11 @@ recently set. *** When editing a bookmark annotation, 'C-c C-k' will now cancel. It is bound to the new command 'bookmark-edit-annotation-cancel'. +--- +*** New option 'bookmark-fringe-mark'. +This option controls the bitmap used to indicate bookmarks in the +fringe (or 'nil' to disable showing this marker). + ** Exif --- diff --git a/lisp/bookmark.el b/lisp/bookmark.el index d0893e932b..7466be32b4 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -181,10 +181,25 @@ A non-nil value may result in truncated bookmark names." "Time before `bookmark-bmenu-search' updates the display." :type 'number) -(defcustom bookmark-set-fringe-mark t - "Whether to set a fringe mark at bookmarked lines." - :type 'boolean - :version "28.1") +(define-fringe-bitmap 'bookmark-mark + [#b01111110 + #b01111110 + #b01111110 + #b01111110 + #b01111110 + #b01111110 + #b01100110 + #b01000010]) + +(define-obsolete-variable-alias 'bookmark-set-fringe-mark + 'bookmark-fringe-mark "29.1") + +(defcustom bookmark-fringe-mark 'bookmark-mark + "The fringe bitmap to mark bookmarked lines with. +If nil, don't display a mark on the fringe." + :type '(choice (const nil) fringe-bitmap) + :set #'fringe-custom-set-bitmap + :version "29.1") ;; FIXME: No longer used. Should be declared obsolete or removed. (defface bookmark-menu-heading @@ -201,10 +216,10 @@ A non-nil value may result in truncated bookmark names." :foreground "LightGray") (((class color) (background light)) - :background "White" :foreground "DarkOrange1") + :foreground "DarkOrange1" :distant-foreground "DarkOrange3") (((class color) (background dark)) - :background "Black" :foreground "DarkOrange1")) + :foreground "DarkOrange1" :distant-foreground "Orange1")) "Face used to highlight current line." :version "28.1") @@ -482,12 +497,9 @@ In other words, return all information but the name." (defvar bookmark-history nil "The history list for bookmark functions.") -(define-fringe-bitmap 'bookmark-fringe-mark - "\x3c\x7e\xff\xff\xff\xff\x7e\x3c") - (defun bookmark--set-fringe-mark () "Apply a colorized overlay to the bookmarked location. -See user option `bookmark-set-fringe-mark'." +See user option `bookmark-fringe-mark'." (let ((bm (make-overlay (point-at-bol) (1+ (point-at-bol))))) (overlay-put bm 'category 'bookmark) (overlay-put bm 'evaporate t) @@ -499,7 +511,7 @@ See user option `bookmark-set-fringe-mark'." (defun bookmark--remove-fringe-mark (bm) "Remove a bookmark's colorized overlay. BM is a bookmark as returned from function `bookmark-get-bookmark'. -See user option `bookmark-set-fringe'." +See user option `bookmark-fringe-mark'." (let ((filename (cdr (assq 'filename bm))) (pos (cdr (assq 'position bm))) overlays found temp) @@ -615,7 +627,7 @@ old one." ;; no prefix arg means just overwrite old bookmark. (let ((bm (bookmark-get-bookmark stripped-name))) ;; First clean up if previously location was fontified. - (when bookmark-set-fringe-mark + (when bookmark-fringe-mark (bookmark--remove-fringe-mark bm)) ;; Modify using the new (NAME . ALIST) format. (setcdr bm alist)) @@ -931,7 +943,7 @@ still there, in order, if the topmost one is ever deleted." ;; Ask for an annotation buffer for this bookmark (when bookmark-use-annotations (bookmark-edit-annotation str)) - (when bookmark-set-fringe-mark + (when bookmark-fringe-mark (bookmark--set-fringe-mark)))) (setq bookmark-yank-point nil) (setq bookmark-current-buffer nil))) @@ -1213,7 +1225,7 @@ and then show any annotations for this bookmark." (if win (set-window-point win (point)))) ;; FIXME: we used to only run bookmark-after-jump-hook in ;; `bookmark-jump' itself, but in none of the other commands. - (when bookmark-set-fringe-mark + (when bookmark-fringe-mark (let ((overlays (overlays-in (point-at-bol) (1+ (point-at-bol)))) temp found) (while (and (not found) (setq temp (pop overlays))) diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index edc09f3199..d5bae8f66f 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -4286,6 +4286,27 @@ restoring it to the state of a face that has never been customized." (widget-put widget :args args) widget)) +;;; The `fringe-bitmap' Widget. + +(defvar widget-fringe-bitmap-prompt-value-history nil + "History of input to `widget-fringe-bitmap-prompt-value'.") + +(define-widget 'fringe-bitmap 'symbol + "A Lisp fringe bitmap name." + :format "%v" + :tag "Fringe bitmap" + :match (lambda (_widget value) (fringe-bitmap-p value)) + :completions (apply-partially #'completion-table-with-predicate + obarray #'fringe-bitmap-p 'strict) + :prompt-match 'fringe-bitmap-p + :prompt-history 'widget-face-prompt-value-history + :validate (lambda (widget) + (unless (fringe-bitmap-p (widget-value widget)) + (widget-put widget + :error (format "Invalid fringe bitmap: %S" + (widget-value widget))) + widget))) + ;;; The `custom-group-link' Widget. (define-widget 'custom-group-link 'link diff --git a/lisp/fringe.el b/lisp/fringe.el index 657a73772d..0c88501298 100644 --- a/lisp/fringe.el +++ b/lisp/fringe.el @@ -46,6 +46,7 @@ (let ((bitmaps '(question-mark exclamation-mark left-arrow right-arrow up-arrow down-arrow left-curly-arrow right-curly-arrow + large-circle left-triangle right-triangle top-left-angle top-right-angle bottom-left-angle bottom-right-angle @@ -324,6 +325,17 @@ If BITMAP already exists, the existing definition is replaced." ;; The real implementation is in src/fringe.c. )) +(defun fringe-custom-set-bitmap (symbol value) + "Set SYMBOL to a fringe bitmap VALUE. +This sets the `fringe' property on SYMBOL to match that of VALUE, +and then force all windows to be updated on the next redisplay. +You should use this for the :set parameter for customization +options to pick a fringe bitmap." + (prog1 + (set symbol value) + (put symbol 'fringe (get value 'fringe)) + (force-window-update))) + (provide 'fringe) ;;; fringe.el ends here diff --git a/src/fringe.c b/src/fringe.c index bf0b5fde76..5d7c8dca99 100644 --- a/src/fringe.c +++ b/src/fringe.c @@ -209,6 +209,20 @@ static unsigned short left_curly_arrow_bits[] = { static unsigned short right_curly_arrow_bits[] = { 0x3c, 0x3e, 0x03, 0x27, 0x3f, 0x3e, 0x3c, 0x3e}; +/* Large circle bitmap. */ +/* + ........ + ..xxxx.. + .xxxxxx. + xxxxxxxx + xxxxxxxx + .xxxxxx. + ..xxxx.. + ........ +*/ +static unsigned short large_circle_bits[] = { + 0x3c, 0x7e, 0xff, 0xff, 0xff, 0xff, 0x7e, 0x3c}; + /* Reverse Overlay arrow bitmap. A triangular arrow. */ /* ......xx @@ -454,6 +468,7 @@ static struct fringe_bitmap standard_bitmaps[] = { FRBITS (down_arrow_bits), 8, 0, ALIGN_BITMAP_BOTTOM, 0 }, { FRBITS (left_curly_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, { FRBITS (right_curly_arrow_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, + { FRBITS (large_circle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, { FRBITS (left_triangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, { FRBITS (right_triangle_bits), 8, 0, ALIGN_BITMAP_CENTER, 0 }, { FRBITS (top_left_angle_bits), 8, 0, ALIGN_BITMAP_TOP, 0 }, commit cf873c1a090b95746cf2f2a9a24a5e4bd7cc2cd6 Author: Jim Porter Date: Sun Aug 14 13:48:22 2022 -0700 Fix non-interactive use of conditionals in Eshell * lisp/eshell/esh-cmd.el (eshell-rewrite-if-command): Fix misplaced 't' symbol; it should be passed to 'eshell-invokify-arg'. (eshell-do-eval): Pass 'synchronous-p' to recursive calls in some missing cases. * test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/if-statement, (esh-cmd-test/if-else-statement) (esh-cmd-test/if-else-statement-lisp-form) (esh-cmd-test/if-else-statement-lisp-form-2) (esh-cmd-test/if-else-statement-ext-cmd) (esh-cmd-test/unless-statement) (esh-cmd-test/unless-else-statement) (esh-cmd-test/unless-else-statement-lisp-form) (esh-cmd-test/unless-else-statement-ext-cmd): Use 'eshell-command-result-equal'. diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 62c95056fd..2f77f3f497 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -607,7 +607,7 @@ must be implemented via rewriting, rather than as a function." t)) (if (= (length terms) 4) `(eshell-protect - ,(eshell-invokify-arg (car (last terms)))) t)))) + ,(eshell-invokify-arg (car (last terms)) t)))))) (defvar eshell-last-command-result) ;Defined in esh-io.el. @@ -1122,7 +1122,7 @@ be finished later after the completion of an asynchronous subprocess." (setcar eshell-test-body nil)) (unless (car eshell-test-body) (setcar eshell-test-body (copy-tree (car args)))) - (while (cadr (eshell-do-eval (car eshell-test-body))) + (while (cadr (eshell-do-eval (car eshell-test-body) synchronous-p)) (setcar eshell-command-body (if (cddr args) `(progn ,@(copy-tree (cdr args))) @@ -1142,7 +1142,8 @@ be finished later after the completion of an asynchronous subprocess." (setcar eshell-test-body (copy-tree (car args)))) (setcar eshell-command-body (copy-tree - (if (cadr (eshell-do-eval (car eshell-test-body))) + (if (cadr (eshell-do-eval (car eshell-test-body) + synchronous-p)) (cadr args) (car (cddr args))))) (eshell-do-eval (car eshell-command-body) synchronous-p)) diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el index c5d780a399..3a582965d6 100644 --- a/test/lisp/eshell/esh-cmd-tests.el +++ b/test/lisp/eshell/esh-cmd-tests.el @@ -188,97 +188,88 @@ e.g. \"{(+ 1 2)} 3\" => 3" (ert-deftest esh-cmd-test/if-statement () "Test invocation of an if statement." - (with-temp-eshell - (let ((eshell-test-value t)) - (eshell-match-command-output "if $eshell-test-value {echo yes}" - "yes\n")) - (let ((eshell-test-value nil)) - (eshell-match-command-output "if $eshell-test-value {echo yes}" - "\\`\\'")))) + (let ((eshell-test-value t)) + (eshell-command-result-equal "if $eshell-test-value {echo yes}" + "yes")) + (let ((eshell-test-value nil)) + (eshell-command-result-equal "if $eshell-test-value {echo yes}" + nil))) (ert-deftest esh-cmd-test/if-else-statement () "Test invocation of an if/else statement." - (with-temp-eshell - (let ((eshell-test-value t)) - (eshell-match-command-output "if $eshell-test-value {echo yes} {echo no}" - "yes\n")) - (let ((eshell-test-value nil)) - (eshell-match-command-output "if $eshell-test-value {echo yes} {echo no}" - "no\n")))) + (let ((eshell-test-value t)) + (eshell-command-result-equal "if $eshell-test-value {echo yes} {echo no}" + "yes")) + (let ((eshell-test-value nil)) + (eshell-command-result-equal "if $eshell-test-value {echo yes} {echo no}" + "no"))) (ert-deftest esh-cmd-test/if-else-statement-lisp-form () "Test invocation of an if/else statement using a Lisp form." - (with-temp-eshell - (eshell-match-command-output "if (zerop 0) {echo yes} {echo no}" - "yes\n") - (eshell-match-command-output "if (zerop 1) {echo yes} {echo no}" - "no\n") - (let ((debug-on-error nil)) - (eshell-match-command-output "if (zerop \"foo\") {echo yes} {echo no}" - "no\n")))) + (eshell-command-result-equal "if (zerop 0) {echo yes} {echo no}" + "yes") + (eshell-command-result-equal "if (zerop 1) {echo yes} {echo no}" + "no") + (let ((debug-on-error nil)) + (eshell-command-result-equal "if (zerop \"foo\") {echo yes} {echo no}" + "no"))) (ert-deftest esh-cmd-test/if-else-statement-lisp-form-2 () "Test invocation of an if/else statement using a Lisp form. This tests when `eshell-lisp-form-nil-is-failure' is nil." (let ((eshell-lisp-form-nil-is-failure nil)) - (with-temp-eshell - (eshell-match-command-output "if (zerop 0) {echo yes} {echo no}" - "yes\n") - (eshell-match-command-output "if (zerop 1) {echo yes} {echo no}" - "yes\n") - (let ((debug-on-error nil)) - (eshell-match-command-output "if (zerop \"foo\") {echo yes} {echo no}" - "no\n"))))) + (eshell-command-result-equal "if (zerop 0) {echo yes} {echo no}" + "yes") + (eshell-command-result-equal "if (zerop 1) {echo yes} {echo no}" + "yes") + (let ((debug-on-error nil)) + (eshell-command-result-equal "if (zerop \"foo\") {echo yes} {echo no}" + "no")))) (ert-deftest esh-cmd-test/if-else-statement-ext-cmd () "Test invocation of an if/else statement using an external command." (skip-unless (executable-find "[")) - (with-temp-eshell - (eshell-match-command-output "if {[ foo = foo ]} {echo yes} {echo no}" - "yes\n") - (eshell-match-command-output "if {[ foo = bar ]} {echo yes} {echo no}" - "no\n"))) + (eshell-command-result-equal "if {[ foo = foo ]} {echo yes} {echo no}" + "yes") + (eshell-command-result-equal "if {[ foo = bar ]} {echo yes} {echo no}" + "no")) (ert-deftest esh-cmd-test/unless-statement () "Test invocation of an unless statement." - (with-temp-eshell - (let ((eshell-test-value t)) - (eshell-match-command-output "unless $eshell-test-value {echo no}" - "\\`\\'")) - (let ((eshell-test-value nil)) - (eshell-match-command-output "unless $eshell-test-value {echo no}" - "no\n")))) + (let ((eshell-test-value t)) + (eshell-command-result-equal "unless $eshell-test-value {echo no}" + nil)) + (let ((eshell-test-value nil)) + (eshell-command-result-equal "unless $eshell-test-value {echo no}" + "no"))) (ert-deftest esh-cmd-test/unless-else-statement () "Test invocation of an unless/else statement." - (with-temp-eshell - (let ((eshell-test-value t)) - (eshell-match-command-output - "unless $eshell-test-value {echo no} {echo yes}" - "yes\n")) - (let ((eshell-test-value nil)) - (eshell-match-command-output - "unless $eshell-test-value {echo no} {echo yes}" - "no\n")))) + (let ((eshell-test-value t)) + (eshell-command-result-equal + "unless $eshell-test-value {echo no} {echo yes}" + "yes")) + (let ((eshell-test-value nil)) + (eshell-command-result-equal + "unless $eshell-test-value {echo no} {echo yes}" + "no"))) (ert-deftest esh-cmd-test/unless-else-statement-lisp-form () "Test invocation of an unless/else statement using a Lisp form." - (with-temp-eshell - (eshell-match-command-output "unless (zerop 0) {echo no} {echo yes}" - "yes\n") - (eshell-match-command-output "unless (zerop 1) {echo no} {echo yes}" - "no\n") - (let ((debug-on-error nil)) - (eshell-match-command-output "unless (zerop \"foo\") {echo no} {echo yes}" - "no\n")))) + (eshell-command-result-equal "unless (zerop 0) {echo no} {echo yes}" + "yes") + (eshell-command-result-equal "unless (zerop 1) {echo no} {echo yes}" + "no") + (let ((debug-on-error nil)) + (eshell-command-result-equal "unless (zerop \"foo\") {echo no} {echo yes}" + "no"))) (ert-deftest esh-cmd-test/unless-else-statement-ext-cmd () "Test invocation of an unless/else statement using an external command." (skip-unless (executable-find "[")) - (with-temp-eshell - (eshell-match-command-output "unless {[ foo = foo ]} {echo no} {echo yes}" - "yes\n") - (eshell-match-command-output "unless {[ foo = bar ]} {echo no} {echo yes}" - "no\n"))) + (eshell-command-result-equal "unless {[ foo = foo ]} {echo no} {echo yes}" + "yes") + (eshell-command-result-equal "unless {[ foo = bar ]} {echo no} {echo yes}" + "no")) ;; esh-cmd-tests.el ends here commit c1f1be4b73072440518f02356998cf58ba127ebd Author: Jim Porter Date: Sun Aug 14 13:44:04 2022 -0700 Add 'eshell-command-result-equal' with an ERT explainer * test/lisp/eshell/eshell-tests-helpers.el (eshell-command-result--equal, eshell-command-result--equal-explainer) (eshell-command-result-equal): New functions. * test/lisp/eshell/em-basic-tests.el * test/lisp/eshell/em-dirs-tests.el * test/lisp/eshell/esh-cmd-tests.el * test/lisp/eshell/esh-proc-tests.el * test/lisp/eshell/esh-var-tests.el * test/lisp/eshell/eshell-tests.el: Use 'eshell-command-result-equal'. diff --git a/test/lisp/eshell/em-basic-tests.el b/test/lisp/eshell/em-basic-tests.el index 7a24f8b46c..bc8baeaa03 100644 --- a/test/lisp/eshell/em-basic-tests.el +++ b/test/lisp/eshell/em-basic-tests.el @@ -36,25 +36,25 @@ (ert-deftest em-basic-test/umask-print-numeric () "Test printing umask numerically." (cl-letf (((symbol-function 'default-file-modes) (lambda () #o775))) - (should (equal (eshell-test-command-result "umask") "002\n"))) + (eshell-command-result-equal "umask" "002\n")) (cl-letf (((symbol-function 'default-file-modes) (lambda () #o654))) - (should (equal (eshell-test-command-result "umask") "123\n"))) + (eshell-command-result-equal "umask" "123\n")) ;; Make sure larger numbers don't cause problems. (cl-letf (((symbol-function 'default-file-modes) (lambda () #o1775))) - (should (equal (eshell-test-command-result "umask") "002\n")))) + (eshell-command-result-equal "umask" "002\n"))) (ert-deftest em-basic-test/umask-read-symbolic () "Test printing umask symbolically." (cl-letf (((symbol-function 'default-file-modes) (lambda () #o775))) - (should (equal (eshell-test-command-result "umask -S") - "u=rwx,g=rwx,o=rx\n"))) + (eshell-command-result-equal "umask -S" + "u=rwx,g=rwx,o=rx\n")) (cl-letf (((symbol-function 'default-file-modes) (lambda () #o654))) - (should (equal (eshell-test-command-result "umask -S") - "u=wx,g=rx,o=x\n"))) + (eshell-command-result-equal "umask -S" + "u=wx,g=rx,o=x\n")) ;; Make sure larger numbers don't cause problems. (cl-letf (((symbol-function 'default-file-modes) (lambda () #o1775))) - (should (equal (eshell-test-command-result "umask -S") - "u=rwx,g=rwx,o=rx\n")))) + (eshell-command-result-equal "umask -S" + "u=rwx,g=rwx,o=rx\n"))) (ert-deftest em-basic-test/umask-set () "Test setting umask." diff --git a/test/lisp/eshell/em-dirs-tests.el b/test/lisp/eshell/em-dirs-tests.el index 9e44ef9851..f72d708dca 100644 --- a/test/lisp/eshell/em-dirs-tests.el +++ b/test/lisp/eshell/em-dirs-tests.el @@ -37,22 +37,22 @@ (ert-deftest em-dirs-test/pwd-var () "Test using the $PWD variable." (let ((default-directory "/some/path")) - (should (equal (eshell-test-command-result "echo $PWD") - (expand-file-name default-directory))))) + (eshell-command-result-equal "echo $PWD" + (expand-file-name default-directory)))) (ert-deftest em-dirs-test/pwd-var-indices () "Test using the $PWD variable with indices." (let ((default-directory "/some/path/here")) - (should (equal (eshell-test-command-result "echo $PWD[/ 1]") - "some")) - (should (equal (eshell-test-command-result "echo $PWD[/ 1 3]") - '("some" "here"))))) + (eshell-command-result-equal "echo $PWD[/ 1]" + "some") + (eshell-command-result-equal "echo $PWD[/ 1 3]" + '("some" "here")))) (ert-deftest em-dirs-test/short-pwd-var () "Test using the $+ (current directory) variable." (let ((default-directory "/some/path")) - (should (equal (eshell-test-command-result "echo $+") - (expand-file-name default-directory))))) + (eshell-command-result-equal "echo $+" + (expand-file-name default-directory)))) (ert-deftest em-dirs-test/oldpwd-var () "Test using the $OLDPWD variable." diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el index 05635e8a7b..c5d780a399 100644 --- a/test/lisp/eshell/esh-cmd-tests.el +++ b/test/lisp/eshell/esh-cmd-tests.el @@ -41,37 +41,37 @@ (ert-deftest esh-cmd-test/simple-command-result () "Test invocation with a simple command." - (should (equal (eshell-test-command-result "+ 1 2") 3))) + (eshell-command-result-equal "+ 1 2" 3)) (ert-deftest esh-cmd-test/lisp-command () "Test invocation with an elisp command." - (should (equal (eshell-test-command-result "(+ 1 2)") 3))) + (eshell-command-result-equal "(+ 1 2)" 3)) (ert-deftest esh-cmd-test/lisp-command-with-quote () "Test invocation with an elisp command containing a quote." - (should (equal (eshell-test-command-result "(eq 'foo nil)") nil))) + (eshell-command-result-equal "(eq 'foo nil)" nil)) (ert-deftest esh-cmd-test/lisp-command-args () "Test invocation with elisp and trailing args. Test that trailing arguments outside the S-expression are ignored. e.g. \"(+ 1 2) 3\" => 3" - (should (equal (eshell-test-command-result "(+ 1 2) 3") 3))) + (eshell-command-result-equal "(+ 1 2) 3" 3)) (ert-deftest esh-cmd-test/subcommand () "Test invocation with a simple subcommand." - (should (equal (eshell-test-command-result "{+ 1 2}") 3))) + (eshell-command-result-equal "{+ 1 2}" 3)) (ert-deftest esh-cmd-test/subcommand-args () "Test invocation with a subcommand and trailing args. Test that trailing arguments outside the subcommand are ignored. e.g. \"{+ 1 2} 3\" => 3" - (should (equal (eshell-test-command-result "{+ 1 2} 3") 3))) + (eshell-command-result-equal "{+ 1 2} 3" 3)) (ert-deftest esh-cmd-test/subcommand-lisp () "Test invocation with an elisp subcommand and trailing args. Test that trailing arguments outside the subcommand are ignored. e.g. \"{(+ 1 2)} 3\" => 3" - (should (equal (eshell-test-command-result "{(+ 1 2)} 3") 3))) + (eshell-command-result-equal "{(+ 1 2)} 3" 3)) ;; Logical operators @@ -118,9 +118,8 @@ e.g. \"{(+ 1 2)} 3\" => 3" (ert-deftest esh-cmd-test/for-name-loop () ; bug#15231 "Test invocation of a for loop using `name'." (let ((process-environment (cons "name" process-environment))) - (should (equal (eshell-test-command-result - "for name in 3 { echo $name }") - 3)))) + (eshell-command-result-equal "for name in 3 { echo $name }" + 3))) (ert-deftest esh-cmd-test/for-name-shadow-loop () ; bug#15372 "Test invocation of a for loop using an env-var." diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el index f538e8c43a..2369bb5cc0 100644 --- a/test/lisp/eshell/esh-proc-tests.el +++ b/test/lisp/eshell/esh-proc-tests.el @@ -56,36 +56,37 @@ (ert-deftest esh-proc-test/pipeline-connection-type/no-pipeline () "Test that all streams are PTYs when a command is not in a pipeline." (skip-unless (executable-find "sh")) - (should (equal (eshell-test-command-result esh-proc-test--detect-pty-cmd) - ;; PTYs aren't supported on MS-Windows. - (unless (eq system-type 'windows-nt) - "stdin\nstdout\nstderr\n")))) + (eshell-command-result-equal + esh-proc-test--detect-pty-cmd + ;; PTYs aren't supported on MS-Windows. + (unless (eq system-type 'windows-nt) + "stdin\nstdout\nstderr\n"))) (ert-deftest esh-proc-test/pipeline-connection-type/first () "Test that only stdin is a PTY when a command starts a pipeline." (skip-unless (and (executable-find "sh") (executable-find "cat"))) - (should (equal (eshell-test-command-result - (concat esh-proc-test--detect-pty-cmd " | cat")) - (unless (eq system-type 'windows-nt) - "stdin\n")))) + (eshell-command-result-equal + (concat esh-proc-test--detect-pty-cmd " | cat") + (unless (eq system-type 'windows-nt) + "stdin\n"))) (ert-deftest esh-proc-test/pipeline-connection-type/middle () "Test that all streams are pipes when a command is in the middle of a pipeline." (skip-unless (and (executable-find "sh") (executable-find "cat"))) - (should (equal (eshell-test-command-result - (concat "echo | " esh-proc-test--detect-pty-cmd " | cat")) - nil))) + (eshell-command-result-equal + (concat "echo | " esh-proc-test--detect-pty-cmd " | cat") + nil)) (ert-deftest esh-proc-test/pipeline-connection-type/last () "Test that only output streams are PTYs when a command ends a pipeline." (skip-unless (executable-find "sh")) - (should (equal (eshell-test-command-result - (concat "echo | " esh-proc-test--detect-pty-cmd)) - (unless (eq system-type 'windows-nt) - "stdout\nstderr\n")))) + (eshell-command-result-equal + (concat "echo | " esh-proc-test--detect-pty-cmd) + (unless (eq system-type 'windows-nt) + "stdout\nstderr\n"))) (ert-deftest esh-proc-test/kill-pipeline () "Test that killing a pipeline of processes only emits a single diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index ca74ad1959..bebc57d359 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el @@ -41,113 +41,107 @@ (ert-deftest esh-var-test/interp-var () "Interpolate variable" - (should (equal (eshell-test-command-result "echo $user-login-name") - user-login-name))) + (eshell-command-result-equal "echo $user-login-name" + user-login-name)) (ert-deftest esh-var-test/interp-quoted-var () "Interpolate quoted variable" - (should (equal (eshell-test-command-result "echo $'user-login-name'") - user-login-name)) - (should (equal (eshell-test-command-result "echo $\"user-login-name\"") - user-login-name))) + (eshell-command-result-equal "echo $'user-login-name'" + user-login-name) + (eshell-command-result-equal "echo $\"user-login-name\"" + user-login-name)) (ert-deftest esh-var-test/interp-quoted-var-concat () "Interpolate and concat quoted variable" - (should (equal (eshell-test-command-result "echo $'user-login-name'-foo") - (concat user-login-name "-foo"))) - (should (equal (eshell-test-command-result "echo $\"user-login-name\"-foo") - (concat user-login-name "-foo")))) + (eshell-command-result-equal "echo $'user-login-name'-foo" + (concat user-login-name "-foo")) + (eshell-command-result-equal "echo $\"user-login-name\"-foo" + (concat user-login-name "-foo"))) (ert-deftest esh-var-test/interp-var-indices () "Interpolate list variable with indices" (let ((eshell-test-value '("zero" "one" "two" "three" "four"))) - (should (equal (eshell-test-command-result "echo $eshell-test-value[0]") - "zero")) - (should (equal (eshell-test-command-result "echo $eshell-test-value[0 2]") - '("zero" "two"))) - (should (equal (eshell-test-command-result "echo $eshell-test-value[0 2 4]") - '("zero" "two" "four"))))) + (eshell-command-result-equal "echo $eshell-test-value[0]" + "zero") + (eshell-command-result-equal "echo $eshell-test-value[0 2]" + '("zero" "two")) + (eshell-command-result-equal "echo $eshell-test-value[0 2 4]" + '("zero" "two" "four")))) (ert-deftest esh-var-test/interp-var-split-indices () "Interpolate string variable with indices" (let ((eshell-test-value "zero one two three four")) - (should (equal (eshell-test-command-result "echo $eshell-test-value[0]") - "zero")) - (should (equal (eshell-test-command-result "echo $eshell-test-value[0 2]") - '("zero" "two"))) - (should (equal (eshell-test-command-result "echo $eshell-test-value[0 2 4]") - '("zero" "two" "four"))))) + (eshell-command-result-equal "echo $eshell-test-value[0]" + "zero") + (eshell-command-result-equal "echo $eshell-test-value[0 2]" + '("zero" "two")) + (eshell-command-result-equal "echo $eshell-test-value[0 2 4]" + '("zero" "two" "four")))) (ert-deftest esh-var-test/interp-var-string-split-indices () "Interpolate string variable with string splitter and indices" (let ((eshell-test-value "zero:one:two:three:four")) - (should (equal (eshell-test-command-result "echo $eshell-test-value[: 0]") - "zero")) - (should (equal (eshell-test-command-result "echo $eshell-test-value[: 0 2]") - '("zero" "two")))) + (eshell-command-result-equal "echo $eshell-test-value[: 0]" + "zero") + (eshell-command-result-equal "echo $eshell-test-value[: 0 2]" + '("zero" "two"))) (let ((eshell-test-value "zeroXoneXtwoXthreeXfour")) - (should (equal (eshell-test-command-result "echo $eshell-test-value[X 0]") - "zero")) - (should (equal (eshell-test-command-result "echo $eshell-test-value[X 0 2]") - '("zero" "two"))))) + (eshell-command-result-equal "echo $eshell-test-value[X 0]" + "zero") + (eshell-command-result-equal "echo $eshell-test-value[X 0 2]" + '("zero" "two")))) (ert-deftest esh-var-test/interp-var-regexp-split-indices () "Interpolate string variable with regexp splitter and indices" (let ((eshell-test-value "zero:one!two:three!four")) - (should (equal (eshell-test-command-result - "echo $eshell-test-value['[:!]' 0]") - "zero")) - (should (equal (eshell-test-command-result - "echo $eshell-test-value['[:!]' 0 2]") - '("zero" "two"))) - (should (equal (eshell-test-command-result - "echo $eshell-test-value[\"[:!]\" 0]") - "zero")) - (should (equal (eshell-test-command-result - "echo $eshell-test-value[\"[:!]\" 0 2]") - '("zero" "two"))))) + (eshell-command-result-equal "echo $eshell-test-value['[:!]' 0]" + "zero") + (eshell-command-result-equal "echo $eshell-test-value['[:!]' 0 2]" + '("zero" "two")) + (eshell-command-result-equal "echo $eshell-test-value[\"[:!]\" 0]" + "zero") + (eshell-command-result-equal "echo $eshell-test-value[\"[:!]\" 0 2]" + '("zero" "two")))) (ert-deftest esh-var-test/interp-var-assoc () "Interpolate alist variable with index" (let ((eshell-test-value '(("foo" . 1)))) - (should (eq (eshell-test-command-result "echo $eshell-test-value[foo]") - 1)))) + (eshell-command-result-equal "echo $eshell-test-value[foo]" + 1))) (ert-deftest esh-var-test/interp-var-length-list () "Interpolate length of list variable" (let ((eshell-test-value '((1 2) (3) (5 (6 7 8 9))))) - (should (eq (eshell-test-command-result "echo $#eshell-test-value") 3)) - (should (eq (eshell-test-command-result "echo $#eshell-test-value[1]") 1)) - (should (eq (eshell-test-command-result "echo $#eshell-test-value[2][1]") - 4)))) + (eshell-command-result-equal "echo $#eshell-test-value" 3) + (eshell-command-result-equal "echo $#eshell-test-value[1]" 1) + (eshell-command-result-equal "echo $#eshell-test-value[2][1]" 4))) (ert-deftest esh-var-test/interp-var-length-string () "Interpolate length of string variable" (let ((eshell-test-value "foobar")) - (should (eq (eshell-test-command-result "echo $#eshell-test-value") 6)))) + (eshell-command-result-equal "echo $#eshell-test-value" 6))) (ert-deftest esh-var-test/interp-var-length-alist () "Interpolate length of alist variable" (let ((eshell-test-value '(("foo" . (1 2 3))))) - (should (eq (eshell-test-command-result "echo $#eshell-test-value") 1)) - (should (eq (eshell-test-command-result "echo $#eshell-test-value[foo]") - 3)))) + (eshell-command-result-equal "echo $#eshell-test-value" 1) + (eshell-command-result-equal "echo $#eshell-test-value[foo]" 3))) (ert-deftest esh-var-test/interp-lisp () "Interpolate Lisp form evaluation" - (should (equal (eshell-test-command-result "+ $(+ 1 2) 3") 6))) + (eshell-command-result-equal "+ $(+ 1 2) 3" 6)) (ert-deftest esh-var-test/interp-lisp-indices () "Interpolate Lisp form evaluation with index" - (should (equal (eshell-test-command-result "+ $(list 1 2)[1] 3") 5))) + (eshell-command-result-equal "+ $(list 1 2)[1] 3" 5)) (ert-deftest esh-var-test/interp-cmd () "Interpolate command result" - (should (equal (eshell-test-command-result "+ ${+ 1 2} 3") 6))) + (eshell-command-result-equal "+ ${+ 1 2} 3" 6)) (ert-deftest esh-var-test/interp-cmd-indices () "Interpolate command result with index" - (should (equal (eshell-test-command-result "+ ${listify 1 2}[1] 3") 5))) + (eshell-command-result-equal "+ ${listify 1 2}[1] 3" 5)) (ert-deftest esh-var-test/interp-cmd-external () "Interpolate command result from external command" @@ -165,32 +159,32 @@ (ert-deftest esh-var-test/interp-temp-cmd () "Interpolate command result redirected to temp file" - (should (equal (eshell-test-command-result "cat $") "hi"))) + (eshell-command-result-equal "cat $" "hi")) (ert-deftest esh-var-test/interp-concat-lisp () "Interpolate and concat Lisp form" - (should (equal (eshell-test-command-result "+ $(+ 1 2)3 3") 36))) + (eshell-command-result-equal "+ $(+ 1 2)3 3" 36)) (ert-deftest esh-var-test/interp-concat-lisp2 () "Interpolate and concat two Lisp forms" - (should (equal (eshell-test-command-result "+ $(+ 1 2)$(+ 1 2) 3") 36))) + (eshell-command-result-equal "+ $(+ 1 2)$(+ 1 2) 3" 36)) (ert-deftest esh-var-test/interp-concat-cmd () "Interpolate and concat command with literal" - (should (equal (eshell-test-command-result "+ ${+ 1 2}3 3") 36)) - (should (equal (eshell-test-command-result "echo ${*echo \"foo\nbar\"}-baz") - '("foo" "bar-baz"))) + (eshell-command-result-equal "+ ${+ 1 2}3 3" 36) + (eshell-command-result-equal "echo ${*echo \"foo\nbar\"}-baz" + '("foo" "bar-baz")) ;; Concatenating to a number in a list should produce a number... - (should (equal (eshell-test-command-result "echo ${*echo \"1\n2\"}3") - '(1 23))) + (eshell-command-result-equal "echo ${*echo \"1\n2\"}3" + '(1 23)) ;; ... but concatenating to a string that looks like a number in a list ;; should produce a string. - (should (equal (eshell-test-command-result "echo ${*echo \"hi\n2\"}3") - '("hi" "23")))) + (eshell-command-result-equal "echo ${*echo \"hi\n2\"}3" + '("hi" "23"))) (ert-deftest esh-var-test/interp-concat-cmd2 () "Interpolate and concat two commands" - (should (equal (eshell-test-command-result "+ ${+ 1 2}${+ 1 2} 3") 36))) + (eshell-command-result-equal "+ ${+ 1 2}${+ 1 2} 3" 36)) (ert-deftest esh-var-test/interp-concat-cmd-external () "Interpolate command result from external command with concatenation" @@ -201,151 +195,128 @@ (ert-deftest esh-var-test/quoted-interp-var () "Interpolate variable inside double-quotes" - (should (equal (eshell-test-command-result "echo \"$user-login-name\"") - user-login-name))) + (eshell-command-result-equal "echo \"$user-login-name\"" + user-login-name)) (ert-deftest esh-var-test/quoted-interp-quoted-var () "Interpolate quoted variable inside double-quotes" - (should (equal (eshell-test-command-result - "echo \"hi, $'user-login-name'\"") - (concat "hi, " user-login-name))) - (should (equal (eshell-test-command-result - "echo \"hi, $\\\"user-login-name\\\"\"") - (concat "hi, " user-login-name)))) + (eshell-command-result-equal "echo \"hi, $'user-login-name'\"" + (concat "hi, " user-login-name)) + (eshell-command-result-equal "echo \"hi, $\\\"user-login-name\\\"\"" + (concat "hi, " user-login-name))) (ert-deftest esh-var-test/quoted-interp-var-indices () "Interpolate string variable with indices inside double-quotes" (let ((eshell-test-value '("zero" "one" "two" "three" "four"))) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[0]\"") - "zero")) + (eshell-command-result-equal "echo \"$eshell-test-value[0]\"" + "zero") ;; FIXME: These tests would use the 0th index like the other tests ;; here, but evaluating the command just above adds an `escaped' ;; property to the string "zero". This results in the output ;; printing the string properties, which is probably the wrong ;; behavior. See bug#54486. - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[1 2]\"") - "(\"one\" \"two\")")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[1 2 4]\"") - "(\"one\" \"two\" \"four\")")))) + (eshell-command-result-equal "echo \"$eshell-test-value[1 2]\"" + "(\"one\" \"two\")") + (eshell-command-result-equal "echo \"$eshell-test-value[1 2 4]\"" + "(\"one\" \"two\" \"four\")"))) (ert-deftest esh-var-test/quoted-interp-var-split-indices () "Interpolate string variable with indices inside double-quotes" (let ((eshell-test-value "zero one two three four")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[0]\"") - "zero")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[0 2]\"") - "(\"zero\" \"two\")")))) + (eshell-command-result-equal "echo \"$eshell-test-value[0]\"" + "zero") + (eshell-command-result-equal "echo \"$eshell-test-value[0 2]\"" + "(\"zero\" \"two\")"))) (ert-deftest esh-var-test/quoted-interp-var-string-split-indices () "Interpolate string variable with string splitter and indices inside double-quotes" (let ((eshell-test-value "zero:one:two:three:four")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[: 0]\"") - "zero")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[: 0 2]\"") - "(\"zero\" \"two\")"))) + (eshell-command-result-equal "echo \"$eshell-test-value[: 0]\"" + "zero") + (eshell-command-result-equal "echo \"$eshell-test-value[: 0 2]\"" + "(\"zero\" \"two\")")) (let ((eshell-test-value "zeroXoneXtwoXthreeXfour")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[X 0]\"") - "zero")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[X 0 2]\"") - "(\"zero\" \"two\")")))) + (eshell-command-result-equal "echo \"$eshell-test-value[X 0]\"" + "zero") + (eshell-command-result-equal "echo \"$eshell-test-value[X 0 2]\"" + "(\"zero\" \"two\")"))) (ert-deftest esh-var-test/quoted-interp-var-regexp-split-indices () "Interpolate string variable with regexp splitter and indices" (let ((eshell-test-value "zero:one!two:three!four")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value['[:!]' 0]\"") - "zero")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value['[:!]' 0 2]\"") - "(\"zero\" \"two\")")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[\\\"[:!]\\\" 0]\"") - "zero")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[\\\"[:!]\\\" 0 2]\"") - "(\"zero\" \"two\")")))) + (eshell-command-result-equal "echo \"$eshell-test-value['[:!]' 0]\"" + "zero") + (eshell-command-result-equal "echo \"$eshell-test-value['[:!]' 0 2]\"" + "(\"zero\" \"two\")") + (eshell-command-result-equal "echo \"$eshell-test-value[\\\"[:!]\\\" 0]\"" + "zero") + (eshell-command-result-equal + "echo \"$eshell-test-value[\\\"[:!]\\\" 0 2]\"" + "(\"zero\" \"two\")"))) (ert-deftest esh-var-test/quoted-interp-var-assoc () "Interpolate alist variable with index inside double-quotes" (let ((eshell-test-value '(("foo" . 1)))) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[foo]\"") - "1")))) + (eshell-command-result-equal "echo \"$eshell-test-value[foo]\"" + "1"))) (ert-deftest esh-var-test/quoted-interp-var-length-list () "Interpolate length of list variable inside double-quotes" (let ((eshell-test-value '((1 2) (3) (5 (6 7 8 9))))) - (should (equal (eshell-test-command-result "echo \"$#eshell-test-value\"") - "3")) - (should (equal (eshell-test-command-result - "echo \"$#eshell-test-value[1]\"") - "1")) - (should (equal (eshell-test-command-result - "echo \"$#eshell-test-value[2][1]\"") - "4")))) + (eshell-command-result-equal "echo \"$#eshell-test-value\"" + "3") + (eshell-command-result-equal "echo \"$#eshell-test-value[1]\"" + "1") + (eshell-command-result-equal "echo \"$#eshell-test-value[2][1]\"" + "4"))) (ert-deftest esh-var-test/quoted-interp-var-length-string () "Interpolate length of string variable inside double-quotes" (let ((eshell-test-value "foobar")) - (should (equal (eshell-test-command-result "echo \"$#eshell-test-value\"") - "6")))) + (eshell-command-result-equal "echo \"$#eshell-test-value\"" + "6"))) (ert-deftest esh-var-test/quoted-interp-var-length-alist () "Interpolate length of alist variable inside double-quotes" (let ((eshell-test-value '(("foo" . (1 2 3))))) - (should (equal (eshell-test-command-result "echo \"$#eshell-test-value\"") - "1")) - (should (equal (eshell-test-command-result - "echo \"$#eshell-test-value[foo]\"") - "3")))) + (eshell-command-result-equal "echo \"$#eshell-test-value\"" + "1") + (eshell-command-result-equal "echo \"$#eshell-test-value[foo]\"" + "3")) (ert-deftest esh-var-test/quoted-interp-lisp () "Interpolate Lisp form evaluation inside double-quotes" - (should (equal (eshell-test-command-result - "echo \"hi $(concat \\\"the\\\" \\\"re\\\")\"") - "hi there"))) + (eshell-command-result-equal "echo \"hi $(concat \\\"the\\\" \\\"re\\\")\"" + "hi there")) (ert-deftest esh-var-test/quoted-interp-lisp-indices () "Interpolate Lisp form evaluation with index" - (should (equal (eshell-test-command-result "concat \"$(list 1 2)[1]\" cool") - "2cool"))) + (eshell-command-result-equal "concat \"$(list 1 2)[1]\" cool" + "2cool")) (ert-deftest esh-var-test/quoted-interp-cmd () "Interpolate command result inside double-quotes" - (should (equal (eshell-test-command-result - "echo \"hi ${echo \\\"there\\\"}\"") - "hi there"))) + (eshell-command-result-equal "echo \"hi ${echo \\\"there\\\"}\"" + "hi there")) (ert-deftest esh-var-test/quoted-interp-cmd-indices () "Interpolate command result with index inside double-quotes" - (should (equal (eshell-test-command-result - "concat \"${listify 1 2}[1]\" cool") - "2cool"))) + (eshell-command-result-equal "concat \"${listify 1 2}[1]\" cool" + "2cool")) (ert-deftest esh-var-test/quoted-interp-temp-cmd () "Interpolate command result redirected to temp file inside double-quotes" (let ((temporary-file-directory (file-name-as-directory (make-temp-file "esh-vars-tests" t)))) (unwind-protect - (should (equal (eshell-test-command-result "cat \"$\"") - "hi")) + (eshell-command-result-equal "cat \"$\"" "hi")) (delete-directory temporary-file-directory t)))) (ert-deftest esh-var-test/quoted-interp-concat-cmd () "Interpolate and concat command with literal" - (should (equal (eshell-test-command-result - "echo \"${echo \\\"foo\nbar\\\"} baz\"") - "foo\nbar baz"))) + (eshell-command-result-equal "echo \"${echo \\\"foo\nbar\\\"} baz\"" + "foo\nbar baz")) ;; Interpolated variable conversion @@ -353,139 +324,129 @@ inside double-quotes" (ert-deftest esh-var-test/interp-convert-var-number () "Interpolate numeric variable" (let ((eshell-test-value 123)) - (should (equal (eshell-test-command-result "type-of $eshell-test-value") - 'integer)))) + (eshell-command-result-equal "type-of $eshell-test-value" + 'integer))) (ert-deftest esh-var-test/interp-convert-var-split-indices () "Interpolate and convert string variable with indices" ;; Check that numeric forms are converted to numbers. (let ((eshell-test-value "000 010 020 030 040")) - (should (equal (eshell-test-command-result "echo $eshell-test-value[0]") - 0)) - (should (equal (eshell-test-command-result "echo $eshell-test-value[0 2]") - '(0 20)))) + (eshell-command-result-equal "echo $eshell-test-value[0]" + 0) + (eshell-command-result-equal "echo $eshell-test-value[0 2]" + '(0 20))) ;; Check that multiline forms are preserved as-is. (let ((eshell-test-value "foo\nbar:baz\n")) - (should (equal (eshell-test-command-result "echo $eshell-test-value[: 0]") - "foo\nbar")) - (should (equal (eshell-test-command-result "echo $eshell-test-value[: 1]") - "baz\n")))) + (eshell-command-result-equal "echo $eshell-test-value[: 0]" + "foo\nbar") + (eshell-command-result-equal "echo $eshell-test-value[: 1]" + "baz\n"))) (ert-deftest esh-var-test/interp-convert-quoted-var-number () "Interpolate numeric quoted numeric variable" (let ((eshell-test-value 123)) - (should (equal (eshell-test-command-result "type-of $'eshell-test-value'") - 'integer)) - (should (equal (eshell-test-command-result "type-of $\"eshell-test-value\"") - 'integer)))) + (eshell-command-result-equal "type-of $'eshell-test-value'" + 'integer) + (eshell-command-result-equal "type-of $\"eshell-test-value\"" + 'integer))) (ert-deftest esh-var-test/interp-convert-quoted-var-split-indices () "Interpolate and convert quoted string variable with indices" (let ((eshell-test-value "000 010 020 030 040")) - (should (equal (eshell-test-command-result "echo $'eshell-test-value'[0]") - 0)) - (should (equal (eshell-test-command-result "echo $'eshell-test-value'[0 2]") - '(0 20))))) + (eshell-command-result-equal "echo $'eshell-test-value'[0]" + 0) + (eshell-command-result-equal "echo $'eshell-test-value'[0 2]" + '(0 20)))) (ert-deftest esh-var-test/interp-convert-cmd-string-newline () "Interpolate trailing-newline command result" - (should (equal (eshell-test-command-result "echo ${echo \"foo\n\"}") "foo"))) + (eshell-command-result-equal "echo ${echo \"foo\n\"}" "foo")) (ert-deftest esh-var-test/interp-convert-cmd-multiline () "Interpolate multi-line command result" - (should (equal (eshell-test-command-result "echo ${echo \"foo\nbar\"}") - '("foo" "bar"))) + (eshell-command-result-equal "echo ${echo \"foo\nbar\"}" + '("foo" "bar")) ;; Numeric output should be converted to numbers... - (should (equal (eshell-test-command-result "echo ${echo \"01\n02\n03\"}") - '(1 2 3))) + (eshell-command-result-equal "echo ${echo \"01\n02\n03\"}" + '(1 2 3)) ;; ... but only if every line is numeric. - (should (equal (eshell-test-command-result "echo ${echo \"01\n02\nhi\"}") - '("01" "02" "hi")))) + (eshell-command-result-equal "echo ${echo \"01\n02\nhi\"}" + '("01" "02" "hi"))) (ert-deftest esh-var-test/interp-convert-cmd-number () "Interpolate numeric command result" - (should (equal (eshell-test-command-result "echo ${echo \"1\"}") 1))) + (eshell-command-result-equal "echo ${echo \"1\"}" 1)) (ert-deftest esh-var-test/interp-convert-cmd-split-indices () "Interpolate command result with indices" - (should (equal (eshell-test-command-result "echo ${echo \"000 010 020\"}[0]") - 0)) - (should (equal (eshell-test-command-result - "echo ${echo \"000 010 020\"}[0 2]") - '(0 20)))) + (eshell-command-result-equal "echo ${echo \"000 010 020\"}[0]" + 0) + (eshell-command-result-equal "echo ${echo \"000 010 020\"}[0 2]" + '(0 20))) (ert-deftest esh-var-test/quoted-interp-convert-var-number () "Interpolate numeric variable inside double-quotes" (let ((eshell-test-value 123)) - (should (equal (eshell-test-command-result "type-of \"$eshell-test-value\"") - 'string)))) + (eshell-command-result-equal "type-of \"$eshell-test-value\"" + 'string))) (ert-deftest esh-var-test/quoted-interp-convert-var-split-indices () "Interpolate string variable with indices inside double-quotes" (let ((eshell-test-value "000 010 020 030 040")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[0]\"") - "000")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[0 2]\"") - "(\"000\" \"020\")")))) + (eshell-command-result-equal "echo \"$eshell-test-value[0]\"" + "000") + (eshell-command-result-equal "echo \"$eshell-test-value[0 2]\"" + "(\"000\" \"020\")"))) (ert-deftest esh-var-test/quoted-interp-convert-quoted-var-number () "Interpolate numeric quoted variable inside double-quotes" (let ((eshell-test-value 123)) - (should (equal (eshell-test-command-result - "type-of \"$'eshell-test-value'\"") - 'string)) - (should (equal (eshell-test-command-result - "type-of \"$\\\"eshell-test-value\\\"\"") - 'string)))) + (eshell-command-result-equal "type-of \"$'eshell-test-value'\"" + 'string) + (eshell-command-result-equal "type-of \"$\\\"eshell-test-value\\\"\"" + 'string))) (ert-deftest esh-var-test/quoted-interp-convert-quoted-var-split-indices () "Interpolate quoted string variable with indices inside double-quotes" (let ((eshell-test-value "000 010 020 030 040")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[0]\"") - "000")) - (should (equal (eshell-test-command-result - "echo \"$eshell-test-value[0 2]\"") - "(\"000\" \"020\")")))) + (eshell-command-result-equal "echo \"$eshell-test-value[0]\"" + "000") + (eshell-command-result-equal "echo \"$eshell-test-value[0 2]\"" + "(\"000\" \"020\")"))) (ert-deftest esh-var-test/quoted-interp-convert-cmd-string-newline () "Interpolate trailing-newline command result inside double-quotes" - (should (equal (eshell-test-command-result "echo \"${echo \\\"foo\n\\\"}\"") - "foo")) - (should (equal (eshell-test-command-result "echo \"${echo \\\"foo\n\n\\\"}\"") - "foo"))) + (eshell-command-result-equal "echo \"${echo \\\"foo\n\\\"}\"" + "foo") + (eshell-command-result-equal "echo \"${echo \\\"foo\n\n\\\"}\"" + "foo")) (ert-deftest esh-var-test/quoted-interp-convert-cmd-multiline () "Interpolate multi-line command result inside double-quotes" - (should (equal (eshell-test-command-result - "echo \"${echo \\\"foo\nbar\\\"}\"") - "foo\nbar"))) + (eshell-command-result-equal "echo \"${echo \\\"foo\nbar\\\"}\"" + "foo\nbar")) (ert-deftest esh-var-test/quoted-interp-convert-cmd-number () "Interpolate numeric command result inside double-quotes" - (should (equal (eshell-test-command-result "echo \"${echo \\\"1\\\"}\"") - "1"))) + (eshell-command-result-equal "echo \"${echo \\\"1\\\"}\"" "1")) (ert-deftest esh-var-test/quoted-interp-convert-cmd-split-indices () "Interpolate command result with indices inside double-quotes" - (should (equal (eshell-test-command-result - "echo \"${echo \\\"000 010 020\\\"}[0]\"") - "000"))) + (eshell-command-result-equal "echo \"${echo \\\"000 010 020\\\"}[0]\"" + "000")) ;; Built-in variables (ert-deftest esh-var-test/lines-var () "$LINES should equal (window-body-height nil 'remap)" - (should (equal (eshell-test-command-result "echo $LINES") - (window-body-height nil 'remap)))) + (eshell-command-result-equal "echo $LINES" + (window-body-height nil 'remap))) (ert-deftest esh-var-test/columns-var () "$COLUMNS should equal (window-body-width nil 'remap)" - (should (equal (eshell-test-command-result "echo $COLUMNS") - (window-body-width nil 'remap)))) + (eshell-command-result-equal "echo $COLUMNS" + (window-body-width nil 'remap))) (ert-deftest esh-var-test/inside-emacs-var () "Test presence of \"INSIDE_EMACS\" in subprocesses" diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/eshell-tests-helpers.el index 778087bd75..8f0f993447 100644 --- a/test/lisp/eshell/eshell-tests-helpers.el +++ b/test/lisp/eshell/eshell-tests-helpers.el @@ -104,6 +104,27 @@ After inserting, call FUNC. If FUNC is nil, instead call (let ((eshell-history-file-name nil)) (eshell-command-result command)))) +(defun eshell-command-result--equal (_command actual expected) + "Compare the ACTUAL result of a COMMAND with its EXPECTED value." + (equal actual expected)) + +(defun eshell-command-result--equal-explainer (command actual expected) + "Explain the result of `eshell-command-result--equal'." + `(nonequal-result + (command ,command) + (result ,actual) + (expected ,expected))) + +(put 'eshell-command-result--equal 'ert-explainer + #'eshell-command-result--equal-explainer) + +(defun eshell-command-result-equal (command result) + "Execute COMMAND non-interactively and compare it to RESULT." + (should (eshell-command-result--equal + command + (eshell-test-command-result command) + result))) + (provide 'eshell-tests-helpers) ;;; eshell-tests-helpers.el ends here diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index c7a9516bea..1845dba280 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el @@ -83,28 +83,27 @@ (dolist (template '("echo {%s} | *cat" "echo ${%s} | *cat" "*cat $<%s> | *cat")) - (should (equal (eshell-test-command-result - (format template "echo $eshell-in-pipeline-p")) - nil)) - (should (equal (eshell-test-command-result - (format template "echo | echo $eshell-in-pipeline-p")) - "last")) - (should (equal (eshell-test-command-result - (format template "echo $eshell-in-pipeline-p | echo")) - "first")) - (should (equal (eshell-test-command-result - (format template - "echo | echo $eshell-in-pipeline-p | echo")) - "t")))) + (eshell-command-result-equal + (format template "echo $eshell-in-pipeline-p") + nil) + (eshell-command-result-equal + (format template "echo | echo $eshell-in-pipeline-p") + "last") + (eshell-command-result-equal + (format template "echo $eshell-in-pipeline-p | echo") + "first") + (eshell-command-result-equal + (format template "echo | echo $eshell-in-pipeline-p | echo") + "t"))) (ert-deftest eshell-test/lisp-reset-in-pipeline () "Check that interpolated Lisp forms reset `eshell-in-pipeline-p'." (skip-unless (executable-find "cat")) (dolist (template '("echo (%s) | *cat" "echo $(%s) | *cat")) - (should (equal (eshell-test-command-result - (format template "format \"%s\" eshell-in-pipeline-p")) - "nil")))) + (eshell-command-result-equal + (format template "format \"%s\" eshell-in-pipeline-p") + "nil"))) (ert-deftest eshell-test/redirect-buffer () "Check that piping to a buffer works" commit 07b8fb197a3057a3419be0335236547e4d7a326b Author: Jim Porter Date: Sat Aug 13 20:31:11 2022 -0700 Provide ERT explainer for 'eshell-match-command-output' This was formerly named 'eshell-command-result-p', but "result" isn't quite the right terminology, since this function specifically tested the output of a command, not its Lisp result (as 'eshell-command-result' would return). * test/lisp/eshell/eshell-tests-helpers.el (eshell-insert-command): Provide a more-complete docstring. (eshell-match-result): Rename to... (eshell-match-output): ... this. (eshell-match-output--explainer): New function. (eshell-command-result-p): Rename to... (eshell-match-command-output): ... this. * test/lisp/eshell/em-alias-tests.el * test/lisp/eshell/em-dirs-tests.el * test/lisp/eshell/em-extpipe-tests.el * test/lisp/eshell/em-script-tests.el * test/lisp/eshell/esh-cmd-tests.el * test/lisp/eshell/esh-proc-tests.el * test/lisp/eshell/esh-var-tests.el * test/lisp/eshell/eshell-tests-helpers.el * test/lisp/eshell/eshell-tests.el: Use 'eshell-match-command-output'. diff --git a/test/lisp/eshell/em-alias-tests.el b/test/lisp/eshell/em-alias-tests.el index 497159e346..aca622220e 100644 --- a/test/lisp/eshell/em-alias-tests.el +++ b/test/lisp/eshell/em-alias-tests.el @@ -38,50 +38,50 @@ "Test a simple alias with no arguments" (with-temp-eshell (eshell-insert-command "alias say-hi 'echo hi'") - (eshell-command-result-p "say-hi" "hi\n") - (eshell-command-result-p "say-hi bye" "hi\n"))) + (eshell-match-command-output "say-hi" "hi\n") + (eshell-match-command-output "say-hi bye" "hi\n"))) (ert-deftest em-alias-test/alias-arg-vars () "Test alias with $0, $1, ... variables" (with-temp-eshell (eshell-insert-command "alias show-args 'printnl $0 \"$1 $2\"'") - (eshell-command-result-p "show-args one two" "show-args\none two\n"))) + (eshell-match-command-output "show-args one two" "show-args\none two\n"))) (ert-deftest em-alias-test/alias-arg-vars-indices () "Test alias with $1, $2, ... variables using indices" (with-temp-eshell (eshell-insert-command "alias funny-sum '+ $1[0] $2[1]'") - (eshell-command-result-p "funny-sum (list 1 2) (list 3 4)" - "5\n"))) + (eshell-match-command-output "funny-sum (list 1 2) (list 3 4)" + "5\n"))) (ert-deftest em-alias-test/alias-arg-vars-split-indices () "Test alias with $0, $1, ... variables using split indices" (with-temp-eshell (eshell-insert-command "alias my-prefix 'echo $0[- 0]'") - (eshell-command-result-p "my-prefix" - "my\n") + (eshell-match-command-output "my-prefix" + "my\n") (eshell-insert-command "alias funny-sum '+ $1[: 0] $2[: 1]'") - (eshell-command-result-p "funny-sum 1:2 3:4" - "5\n"))) + (eshell-match-command-output "funny-sum 1:2 3:4" + "5\n"))) (ert-deftest em-alias-test/alias-all-args-var () "Test alias with the $* variable" (with-temp-eshell (eshell-insert-command "alias show-all-args 'printnl $*'") - (eshell-command-result-p "show-all-args" "\\`\\'") - (eshell-command-result-p "show-all-args a" "a\n") - (eshell-command-result-p "show-all-args a b c" "a\nb\nc\n"))) + (eshell-match-command-output "show-all-args" "\\`\\'") + (eshell-match-command-output "show-all-args a" "a\n") + (eshell-match-command-output "show-all-args a b c" "a\nb\nc\n"))) (ert-deftest em-alias-test/alias-all-args-var-indices () "Test alias with the $* variable using indices" (with-temp-eshell (eshell-insert-command "alias add-pair '+ $*[0] $*[1]'") - (eshell-command-result-p "add-pair 1 2" "3\n"))) + (eshell-match-command-output "add-pair 1 2" "3\n"))) (ert-deftest em-alias-test/alias-all-args-var-split-indices () "Test alias with the $* variable using split indices" (with-temp-eshell (eshell-insert-command "alias add-funny-pair '+ $*[0][: 0] $*[1][: 1]'") - (eshell-command-result-p "add-funny-pair 1:2 3:4" "5\n"))) + (eshell-match-command-output "add-funny-pair 1:2 3:4" "5\n"))) ;; em-alias-tests.el ends here diff --git a/test/lisp/eshell/em-dirs-tests.el b/test/lisp/eshell/em-dirs-tests.el index 8e96cc0747..9e44ef9851 100644 --- a/test/lisp/eshell/em-dirs-tests.el +++ b/test/lisp/eshell/em-dirs-tests.el @@ -58,45 +58,45 @@ "Test using the $OLDPWD variable." (let (eshell-last-dir-ring-file-name) (with-temp-eshell - (eshell-command-result-p "echo $OLDPWD" - "\\`\\'") + (eshell-match-command-output "echo $OLDPWD" + "\\`\\'") (ring-insert eshell-last-dir-ring "/some/path") - (eshell-command-result-p "echo $OLDPWD" - "/some/path\n")))) + (eshell-match-command-output "echo $OLDPWD" + "/some/path\n")))) (ert-deftest em-dirs-test/oldpwd-var-indices () "Test using the $OLDPWD variable with indices." (let (eshell-last-dir-ring-file-name) (with-temp-eshell (ring-insert eshell-last-dir-ring "/some/path/here") - (eshell-command-result-p "echo $OLDPWD[/ 1]" - "some\n") - (eshell-command-result-p "echo $OLDPWD[/ 1 3]" - "(\"some\" \"here\")\n")))) + (eshell-match-command-output "echo $OLDPWD[/ 1]" + "some\n") + (eshell-match-command-output "echo $OLDPWD[/ 1 3]" + "(\"some\" \"here\")\n")))) (ert-deftest em-dirs-test/directory-ring-var () "Test using the $- (directory ring) variable." (let (eshell-last-dir-ring-file-name) (with-temp-eshell - (eshell-command-result-p "echo $-" - "\\`\\'") + (eshell-match-command-output "echo $-" + "\\`\\'") (ring-insert eshell-last-dir-ring "/some/path") (ring-insert eshell-last-dir-ring "/other/path") - (eshell-command-result-p "echo $-" - "/other/path\n") - (eshell-command-result-p "echo $-[0]" - "/other/path\n") - (eshell-command-result-p "echo $-[1]" - "/some/path\n")))) + (eshell-match-command-output "echo $-" + "/other/path\n") + (eshell-match-command-output "echo $-[0]" + "/other/path\n") + (eshell-match-command-output "echo $-[1]" + "/some/path\n")))) (ert-deftest em-dirs-test/directory-ring-var-indices () "Test using the $- (directory ring) variable with multiple indices." (let (eshell-last-dir-ring-file-name) (with-temp-eshell (ring-insert eshell-last-dir-ring "/some/path/here") - (eshell-command-result-p "echo $-[0][/ 1]" - "some\n") - (eshell-command-result-p "echo $-[1][/ 1 3]" - "(\"some\" \"here\")\n")))) + (eshell-match-command-output "echo $-[0][/ 1]" + "some\n") + (eshell-match-command-output "echo $-[1][/ 1 3]" + "(\"some\" \"here\")\n")))) ;; em-dirs-tests.el ends here diff --git a/test/lisp/eshell/em-extpipe-tests.el b/test/lisp/eshell/em-extpipe-tests.el index 29f5dc0551..04e7827942 100644 --- a/test/lisp/eshell/em-extpipe-tests.el +++ b/test/lisp/eshell/em-extpipe-tests.el @@ -80,7 +80,7 @@ (should-parse '(eshell-named-command "sh" (list "-c" "echo \"bar\" | rev >temp"))) (with-substitute-for-temp - (eshell-command-result-p input "^$") + (eshell-match-command-output input "^$") (temp-should-string= "rab"))) (em-extpipe-tests--deftest em-extpipe-test-2 @@ -91,7 +91,7 @@ '((eshell-named-command "echo" (list (eshell-escape-arg "bar"))) (eshell-named-command "sh" (list "-c" "rev >temp"))))) (with-substitute-for-temp - (eshell-command-result-p input "^$") + (eshell-match-command-output input "^$") (temp-should-string= "rab"))) (em-extpipe-tests--deftest em-extpipe-test-3 "foo *| bar | baz -d" @@ -111,7 +111,7 @@ (eshell-named-command "sh" (list "-c" "echo \"bar\" | rev")))) (with-substitute-for-temp - (eshell-command-result-p input "^$") + (eshell-match-command-output input "^$") (temp-buffer-should-string= "rab"))) (em-extpipe-tests--deftest em-extpipe-test-5 @@ -177,7 +177,7 @@ (should-parse '(eshell-named-command "sh" (list "-c" "tac 3" "Test logical && operator." (skip-unless (executable-find "[")) (with-temp-eshell - (eshell-command-result-p "[ foo = foo ] && echo hi" - "hi\n") - (eshell-command-result-p "[ foo = bar ] && echo hi" - "\\`\\'"))) + (eshell-match-command-output "[ foo = foo ] && echo hi" + "hi\n") + (eshell-match-command-output "[ foo = bar ] && echo hi" + "\\`\\'"))) (ert-deftest esh-cmd-test/or-operator () "Test logical || operator." (skip-unless (executable-find "[")) (with-temp-eshell - (eshell-command-result-p "[ foo = foo ] || echo hi" - "\\`\\'") - (eshell-command-result-p "[ foo = bar ] || echo hi" - "hi\n"))) + (eshell-match-command-output "[ foo = foo ] || echo hi" + "\\`\\'") + (eshell-match-command-output "[ foo = bar ] || echo hi" + "hi\n"))) ;; Control flow statements @@ -100,20 +100,20 @@ e.g. \"{(+ 1 2)} 3\" => 3" (ert-deftest esh-cmd-test/for-loop () "Test invocation of a for loop." (with-temp-eshell - (eshell-command-result-p "for i in 5 { echo $i }" - "5\n"))) + (eshell-match-command-output "for i in 5 { echo $i }" + "5\n"))) (ert-deftest esh-cmd-test/for-loop-list () "Test invocation of a for loop iterating over a list." (with-temp-eshell - (eshell-command-result-p "for i in (list 1 2 (list 3 4)) { echo $i }" - "1\n2\n(3 4)\n"))) + (eshell-match-command-output "for i in (list 1 2 (list 3 4)) { echo $i }" + "1\n2\n(3 4)\n"))) (ert-deftest esh-cmd-test/for-loop-multiple-args () "Test invocation of a for loop iterating over multiple arguments." (with-temp-eshell - (eshell-command-result-p "for i in 1 2 (list 3 4) { echo $i }" - "1\n2\n3\n4\n"))) + (eshell-match-command-output "for i in 1 2 (list 3 4) { echo $i }" + "1\n2\n3\n4\n"))) (ert-deftest esh-cmd-test/for-name-loop () ; bug#15231 "Test invocation of a for loop using `name'." @@ -126,7 +126,7 @@ e.g. \"{(+ 1 2)} 3\" => 3" "Test invocation of a for loop using an env-var." (let ((process-environment (cons "name=env-value" process-environment))) (with-temp-eshell - (eshell-command-result-p + (eshell-match-command-output "echo $name; for name in 3 { echo $name }; echo $name" "env-value\n3\nenv-value\n")))) @@ -134,7 +134,7 @@ e.g. \"{(+ 1 2)} 3\" => 3" "Test invocation of a while loop." (with-temp-eshell (let ((eshell-test-value '(0 1 2))) - (eshell-command-result-p + (eshell-match-command-output (concat "while $eshell-test-value " "{ setq eshell-test-value (cdr eshell-test-value) }") "(1 2)\n(2)\n")))) @@ -143,7 +143,7 @@ e.g. \"{(+ 1 2)} 3\" => 3" "Test invocation of a while loop using a Lisp form." (with-temp-eshell (let ((eshell-test-value 0)) - (eshell-command-result-p + (eshell-match-command-output (concat "while (/= eshell-test-value 3) " "{ setq eshell-test-value (1+ eshell-test-value) }") "1\n2\n3\n")))) @@ -153,7 +153,7 @@ e.g. \"{(+ 1 2)} 3\" => 3" (skip-unless (executable-find "[")) (with-temp-eshell (let ((eshell-test-value 0)) - (eshell-command-result-p + (eshell-match-command-output (concat "while {[ $eshell-test-value -ne 3 ]} " "{ setq eshell-test-value (1+ eshell-test-value) }") "1\n2\n3\n")))) @@ -162,7 +162,7 @@ e.g. \"{(+ 1 2)} 3\" => 3" "Test invocation of an until loop." (with-temp-eshell (let ((eshell-test-value nil)) - (eshell-command-result-p + (eshell-match-command-output (concat "until $eshell-test-value " "{ setq eshell-test-value t }") "t\n")))) @@ -172,7 +172,7 @@ e.g. \"{(+ 1 2)} 3\" => 3" (skip-unless (executable-find "[")) (with-temp-eshell (let ((eshell-test-value 0)) - (eshell-command-result-p + (eshell-match-command-output (concat "until (= eshell-test-value 3) " "{ setq eshell-test-value (1+ eshell-test-value) }") "1\n2\n3\n")))) @@ -182,7 +182,7 @@ e.g. \"{(+ 1 2)} 3\" => 3" (skip-unless (executable-find "[")) (with-temp-eshell (let ((eshell-test-value 0)) - (eshell-command-result-p + (eshell-match-command-output (concat "until {[ $eshell-test-value -eq 3 ]} " "{ setq eshell-test-value (1+ eshell-test-value) }") "1\n2\n3\n")))) @@ -191,93 +191,95 @@ e.g. \"{(+ 1 2)} 3\" => 3" "Test invocation of an if statement." (with-temp-eshell (let ((eshell-test-value t)) - (eshell-command-result-p "if $eshell-test-value {echo yes}" - "yes\n")) + (eshell-match-command-output "if $eshell-test-value {echo yes}" + "yes\n")) (let ((eshell-test-value nil)) - (eshell-command-result-p "if $eshell-test-value {echo yes}" - "\\`\\'")))) + (eshell-match-command-output "if $eshell-test-value {echo yes}" + "\\`\\'")))) (ert-deftest esh-cmd-test/if-else-statement () "Test invocation of an if/else statement." (with-temp-eshell (let ((eshell-test-value t)) - (eshell-command-result-p "if $eshell-test-value {echo yes} {echo no}" - "yes\n")) + (eshell-match-command-output "if $eshell-test-value {echo yes} {echo no}" + "yes\n")) (let ((eshell-test-value nil)) - (eshell-command-result-p "if $eshell-test-value {echo yes} {echo no}" - "no\n")))) + (eshell-match-command-output "if $eshell-test-value {echo yes} {echo no}" + "no\n")))) (ert-deftest esh-cmd-test/if-else-statement-lisp-form () "Test invocation of an if/else statement using a Lisp form." (with-temp-eshell - (eshell-command-result-p "if (zerop 0) {echo yes} {echo no}" - "yes\n") - (eshell-command-result-p "if (zerop 1) {echo yes} {echo no}" - "no\n") + (eshell-match-command-output "if (zerop 0) {echo yes} {echo no}" + "yes\n") + (eshell-match-command-output "if (zerop 1) {echo yes} {echo no}" + "no\n") (let ((debug-on-error nil)) - (eshell-command-result-p "if (zerop \"foo\") {echo yes} {echo no}" - "no\n")))) + (eshell-match-command-output "if (zerop \"foo\") {echo yes} {echo no}" + "no\n")))) (ert-deftest esh-cmd-test/if-else-statement-lisp-form-2 () "Test invocation of an if/else statement using a Lisp form. This tests when `eshell-lisp-form-nil-is-failure' is nil." (let ((eshell-lisp-form-nil-is-failure nil)) (with-temp-eshell - (eshell-command-result-p "if (zerop 0) {echo yes} {echo no}" - "yes\n") - (eshell-command-result-p "if (zerop 1) {echo yes} {echo no}" - "yes\n") + (eshell-match-command-output "if (zerop 0) {echo yes} {echo no}" + "yes\n") + (eshell-match-command-output "if (zerop 1) {echo yes} {echo no}" + "yes\n") (let ((debug-on-error nil)) - (eshell-command-result-p "if (zerop \"foo\") {echo yes} {echo no}" - "no\n"))))) + (eshell-match-command-output "if (zerop \"foo\") {echo yes} {echo no}" + "no\n"))))) (ert-deftest esh-cmd-test/if-else-statement-ext-cmd () "Test invocation of an if/else statement using an external command." (skip-unless (executable-find "[")) (with-temp-eshell - (eshell-command-result-p "if {[ foo = foo ]} {echo yes} {echo no}" - "yes\n") - (eshell-command-result-p "if {[ foo = bar ]} {echo yes} {echo no}" - "no\n"))) + (eshell-match-command-output "if {[ foo = foo ]} {echo yes} {echo no}" + "yes\n") + (eshell-match-command-output "if {[ foo = bar ]} {echo yes} {echo no}" + "no\n"))) (ert-deftest esh-cmd-test/unless-statement () "Test invocation of an unless statement." (with-temp-eshell (let ((eshell-test-value t)) - (eshell-command-result-p "unless $eshell-test-value {echo no}" - "\\`\\'")) + (eshell-match-command-output "unless $eshell-test-value {echo no}" + "\\`\\'")) (let ((eshell-test-value nil)) - (eshell-command-result-p "unless $eshell-test-value {echo no}" - "no\n")))) + (eshell-match-command-output "unless $eshell-test-value {echo no}" + "no\n")))) (ert-deftest esh-cmd-test/unless-else-statement () "Test invocation of an unless/else statement." (with-temp-eshell (let ((eshell-test-value t)) - (eshell-command-result-p "unless $eshell-test-value {echo no} {echo yes}" - "yes\n")) + (eshell-match-command-output + "unless $eshell-test-value {echo no} {echo yes}" + "yes\n")) (let ((eshell-test-value nil)) - (eshell-command-result-p "unless $eshell-test-value {echo no} {echo yes}" - "no\n")))) + (eshell-match-command-output + "unless $eshell-test-value {echo no} {echo yes}" + "no\n")))) (ert-deftest esh-cmd-test/unless-else-statement-lisp-form () "Test invocation of an unless/else statement using a Lisp form." (with-temp-eshell - (eshell-command-result-p "unless (zerop 0) {echo no} {echo yes}" - "yes\n") - (eshell-command-result-p "unless (zerop 1) {echo no} {echo yes}" - "no\n") + (eshell-match-command-output "unless (zerop 0) {echo no} {echo yes}" + "yes\n") + (eshell-match-command-output "unless (zerop 1) {echo no} {echo yes}" + "no\n") (let ((debug-on-error nil)) - (eshell-command-result-p "unless (zerop \"foo\") {echo no} {echo yes}" - "no\n")))) + (eshell-match-command-output "unless (zerop \"foo\") {echo no} {echo yes}" + "no\n")))) (ert-deftest esh-cmd-test/unless-else-statement-ext-cmd () "Test invocation of an unless/else statement using an external command." (skip-unless (executable-find "[")) (with-temp-eshell - (eshell-command-result-p "unless {[ foo = foo ]} {echo no} {echo yes}" - "yes\n") - (eshell-command-result-p "unless {[ foo = bar ]} {echo no} {echo yes}" - "no\n"))) + (eshell-match-command-output "unless {[ foo = foo ]} {echo no} {echo yes}" + "yes\n") + (eshell-match-command-output "unless {[ foo = bar ]} {echo no} {echo yes}" + "no\n"))) ;; esh-cmd-tests.el ends here diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el index 734bb91a6a..f538e8c43a 100644 --- a/test/lisp/eshell/esh-proc-tests.el +++ b/test/lisp/eshell/esh-proc-tests.el @@ -43,7 +43,7 @@ (executable-find "echo") (executable-find "sleep"))) (with-temp-eshell - (eshell-command-result-p + (eshell-match-command-output ;; The first command is like `yes' but slower. This is to prevent ;; it from taxing Emacs's process filter too much and causing a ;; hang. @@ -136,4 +136,4 @@ prompt. See bug#54136." (kill-process (caar eshell-process-list)) ;; Give `eshell-sentinel' a chance to run. (sit-for 0.1) - (eshell-match-result "\\[sh\\(\\.exe\\)?\\] [[:digit:]]+\n"))) + (should (eshell-match-output "\\[sh\\(\\.exe\\)?\\] [[:digit:]]+\n")))) diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index 0c094ee5a7..ca74ad1959 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el @@ -153,15 +153,15 @@ "Interpolate command result from external command" (skip-unless (executable-find "echo")) (with-temp-eshell - (eshell-command-result-p "echo ${*echo hi}" - "hi\n"))) + (eshell-match-command-output "echo ${*echo hi}" + "hi\n"))) (ert-deftest esh-var-test/interp-cmd-external-indices () "Interpolate command result from external command with index" (skip-unless (executable-find "echo")) (with-temp-eshell - (eshell-command-result-p "echo ${*echo \"hi\nbye\"}[1]" - "bye\n"))) + (eshell-match-command-output "echo ${*echo \"hi\nbye\"}[1]" + "bye\n"))) (ert-deftest esh-var-test/interp-temp-cmd () "Interpolate command result redirected to temp file" @@ -196,8 +196,8 @@ "Interpolate command result from external command with concatenation" (skip-unless (executable-find "echo")) (with-temp-eshell - (eshell-command-result-p "echo ${echo hi}-${*echo there}" - "hi-there\n"))) + (eshell-match-command-output "echo ${echo hi}-${*echo there}" + "hi-there\n"))) (ert-deftest esh-var-test/quoted-interp-var () "Interpolate variable inside double-quotes" @@ -490,72 +490,72 @@ inside double-quotes" (ert-deftest esh-var-test/inside-emacs-var () "Test presence of \"INSIDE_EMACS\" in subprocesses" (with-temp-eshell - (eshell-command-result-p "env" - (format "INSIDE_EMACS=%s,eshell" - emacs-version)))) + (eshell-match-command-output "env" + (format "INSIDE_EMACS=%s,eshell" + emacs-version)))) (ert-deftest esh-var-test/inside-emacs-var-split-indices () "Test using \"INSIDE_EMACS\" with split indices" (with-temp-eshell - (eshell-command-result-p "echo $INSIDE_EMACS[, 1]" - "eshell"))) + (eshell-match-command-output "echo $INSIDE_EMACS[, 1]" + "eshell"))) (ert-deftest esh-var-test/last-status-var-lisp-command () "Test using the \"last exit status\" ($?) variable with a Lisp command" (with-temp-eshell - (eshell-command-result-p "zerop 0; echo $?" - "t\n0\n") - (eshell-command-result-p "zerop 1; echo $?" - "0\n") + (eshell-match-command-output "zerop 0; echo $?" + "t\n0\n") + (eshell-match-command-output "zerop 1; echo $?" + "0\n") (let ((debug-on-error nil)) - (eshell-command-result-p "zerop foo; echo $?" - "1\n")))) + (eshell-match-command-output "zerop foo; echo $?" + "1\n")))) (ert-deftest esh-var-test/last-status-var-lisp-form () "Test using the \"last exit status\" ($?) variable with a Lisp form" (let ((eshell-lisp-form-nil-is-failure t)) - (with-temp-eshell - (eshell-command-result-p "(zerop 0); echo $?" - "t\n0\n") - (eshell-command-result-p "(zerop 1); echo $?" - "2\n") - (let ((debug-on-error nil)) - (eshell-command-result-p "(zerop \"foo\"); echo $?" - "1\n"))))) + (with-temp-eshell + (eshell-match-command-output "(zerop 0); echo $?" + "t\n0\n") + (eshell-match-command-output "(zerop 1); echo $?" + "2\n") + (let ((debug-on-error nil)) + (eshell-match-command-output "(zerop \"foo\"); echo $?" + "1\n"))))) (ert-deftest esh-var-test/last-status-var-lisp-form-2 () "Test using the \"last exit status\" ($?) variable with a Lisp form. This tests when `eshell-lisp-form-nil-is-failure' is nil." (let ((eshell-lisp-form-nil-is-failure nil)) (with-temp-eshell - (eshell-command-result-p "(zerop 0); echo $?" - "0\n") - (eshell-command-result-p "(zerop 0); echo $?" - "0\n") + (eshell-match-command-output "(zerop 0); echo $?" + "0\n") + (eshell-match-command-output "(zerop 0); echo $?" + "0\n") (let ((debug-on-error nil)) - (eshell-command-result-p "(zerop \"foo\"); echo $?" - "1\n"))))) + (eshell-match-command-output "(zerop \"foo\"); echo $?" + "1\n"))))) (ert-deftest esh-var-test/last-status-var-ext-cmd () "Test using the \"last exit status\" ($?) variable with an external command" (skip-unless (executable-find "[")) (with-temp-eshell - (eshell-command-result-p "[ foo = foo ]; echo $?" - "0\n") - (eshell-command-result-p "[ foo = bar ]; echo $?" - "1\n"))) + (eshell-match-command-output "[ foo = foo ]; echo $?" + "0\n") + (eshell-match-command-output "[ foo = bar ]; echo $?" + "1\n"))) (ert-deftest esh-var-test/last-result-var () "Test using the \"last result\" ($$) variable" (with-temp-eshell - (eshell-command-result-p "+ 1 2; + $$ 2" - "3\n5\n"))) + (eshell-match-command-output "+ 1 2; + $$ 2" + "3\n5\n"))) (ert-deftest esh-var-test/last-result-var-twice () "Test using the \"last result\" ($$) variable twice" (with-temp-eshell - (eshell-command-result-p "+ 1 2; + $$ $$" - "3\n6\n"))) + (eshell-match-command-output "+ 1 2; + $$ $$" + "3\n6\n"))) (ert-deftest esh-var-test/last-result-var-ext-cmd () "Test using the \"last result\" ($$) variable with an external command" @@ -564,41 +564,41 @@ This tests when `eshell-lisp-form-nil-is-failure' is nil." ;; MS-DOS/MS-Windows have an external command 'format', which we ;; don't want here. (let ((eshell-prefer-lisp-functions t)) - (eshell-command-result-p "[ foo = foo ]; format \"%s\" $$" - "t\n") - (eshell-command-result-p "[ foo = bar ]; format \"%s\" $$" - "nil\n")))) + (eshell-match-command-output "[ foo = foo ]; format \"%s\" $$" + "t\n") + (eshell-match-command-output "[ foo = bar ]; format \"%s\" $$" + "nil\n")))) (ert-deftest esh-var-test/last-result-var-split-indices () "Test using the \"last result\" ($$) variable with split indices" (with-temp-eshell - (eshell-command-result-p + (eshell-match-command-output "string-join (list \"01\" \"02\") :; + $$[: 1] 3" "01:02\n5\n") - (eshell-command-result-p + (eshell-match-command-output "string-join (list \"01\" \"02\") :; echo \"$$[: 1]\"" "01:02\n02\n"))) (ert-deftest esh-var-test/last-arg-var () "Test using the \"last arg\" ($_) variable" (with-temp-eshell - (eshell-command-result-p "+ 1 2; + $_ 4" - "3\n6\n"))) + (eshell-match-command-output "+ 1 2; + $_ 4" + "3\n6\n"))) (ert-deftest esh-var-test/last-arg-var-indices () "Test using the \"last arg\" ($_) variable with indices" (with-temp-eshell - (eshell-command-result-p "+ 1 2; + $_[0] 4" - "3\n5\n") - (eshell-command-result-p "+ 1 2; + $_[1] 4" - "3\n6\n"))) + (eshell-match-command-output "+ 1 2; + $_[0] 4" + "3\n5\n") + (eshell-match-command-output "+ 1 2; + $_[1] 4" + "3\n6\n"))) (ert-deftest esh-var-test/last-arg-var-split-indices () "Test using the \"last arg\" ($_) variable with split indices" (with-temp-eshell - (eshell-command-result-p "concat 01:02 03:04; + $_[0][: 1] 5" - "01:0203:04\n7\n") - (eshell-command-result-p "concat 01:02 03:04; echo \"$_[0][: 1]\"" - "01:0203:04\n02\n"))) + (eshell-match-command-output "concat 01:02 03:04; + $_[0][: 1] 5" + "01:0203:04\n7\n") + (eshell-match-command-output "concat 01:02 03:04; echo \"$_[0][: 1]\"" + "01:0203:04\n02\n"))) ;; esh-var-tests.el ends here diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/eshell-tests-helpers.el index 4ad76ca697..778087bd75 100644 --- a/test/lisp/eshell/eshell-tests-helpers.el +++ b/test/lisp/eshell/eshell-tests-helpers.el @@ -65,24 +65,36 @@ raise an error." (error "timed out waiting for subprocess(es)")) (sit-for 0.1)))) -(defun eshell-insert-command (text &optional func) - "Insert a command at the end of the buffer." +(defun eshell-insert-command (command &optional func) + "Insert a COMMAND at the end of the buffer. +After inserting, call FUNC. If FUNC is nil, instead call +`eshell-send-input'." (goto-char eshell-last-output-end) - (insert-and-inherit text) + (insert-and-inherit command) (funcall (or func 'eshell-send-input))) -(defun eshell-match-result (regexp) - "Check that output of last command matches REGEXP." - (should - (string-match-p +(defun eshell-match-output (regexp) + "Test whether the output of the last command matches REGEXP." + (string-match-p regexp (buffer-substring-no-properties - (eshell-beginning-of-output) (eshell-end-of-output))))) - -(defun eshell-command-result-p (text regexp &optional func) - "Insert a command at the end of the buffer." - (eshell-insert-command text func) + (eshell-beginning-of-output) (eshell-end-of-output)))) + +(defun eshell-match-output--explainer (regexp) + "Explain the result of `eshell-match-output'." + `(mismatched-output + (command ,(buffer-substring-no-properties + eshell-last-input-start eshell-last-input-end)) + (output ,(buffer-substring-no-properties + (eshell-beginning-of-output) (eshell-end-of-output))) + (regexp ,regexp))) + +(put 'eshell-match-output 'ert-explainer #'eshell-match-output--explainer) + +(defun eshell-match-command-output (command regexp &optional func) + "Insert a COMMAND at the end of the buffer and match the output with REGEXP." + (eshell-insert-command command func) (eshell-wait-for-subprocess) - (eshell-match-result regexp)) + (should (eshell-match-output regexp))) (defvar eshell-history-file-name) diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index 8423500ea7..c7a9516bea 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el @@ -40,15 +40,15 @@ "Check that piping a non-process to a process command waits for the process" (skip-unless (executable-find "cat")) (with-temp-eshell - (eshell-command-result-p "echo hi | *cat" - "hi"))) + (eshell-match-command-output "echo hi | *cat" + "hi"))) (ert-deftest eshell-test/pipe-tailproc () "Check that piping a process to a non-process command waits for the process" (skip-unless (executable-find "echo")) (with-temp-eshell - (eshell-command-result-p "*echo hi | echo bye" - "bye\nhi\n"))) + (eshell-match-command-output "*echo hi | echo bye" + "bye\nhi\n"))) (ert-deftest eshell-test/pipe-headproc-stdin () "Check that standard input is sent to the head process in a pipeline" @@ -59,23 +59,23 @@ (eshell-insert-command "hello") (eshell-send-eof-to-process) (eshell-wait-for-subprocess) - (eshell-match-result "OLLEH\n"))) + (should (eshell-match-output "OLLEH\n")))) (ert-deftest eshell-test/pipe-subcommand () "Check that piping with an asynchronous subcommand works" (skip-unless (and (executable-find "echo") (executable-find "cat"))) (with-temp-eshell - (eshell-command-result-p "echo ${*echo hi} | *cat" - "hi"))) + (eshell-match-command-output "echo ${*echo hi} | *cat" + "hi"))) (ert-deftest eshell-test/pipe-subcommand-with-pipe () "Check that piping with an asynchronous subcommand with its own pipe works" (skip-unless (and (executable-find "echo") (executable-find "cat"))) (with-temp-eshell - (eshell-command-result-p "echo ${*echo hi | *cat} | *cat" - "hi"))) + (eshell-match-command-output "echo ${*echo hi | *cat} | *cat" + "hi"))) (ert-deftest eshell-test/subcommand-reset-in-pipeline () "Check that subcommands reset `eshell-in-pipeline-p'." @@ -129,32 +129,32 @@ "Test that \"\\c\" and \"c\" are equivalent when \"c\" is not a special character." (with-temp-eshell - (eshell-command-result-p "echo he\\llo" - "hello\n"))) + (eshell-match-command-output "echo he\\llo" + "hello\n"))) (ert-deftest eshell-test/escape-nonspecial-unicode () "Test that \"\\c\" and \"c\" are equivalent when \"c\" is a unicode character (unicode characters are nonspecial by definition)." (with-temp-eshell - (eshell-command-result-p "echo Vid\\éos" - "Vidéos\n"))) + (eshell-match-command-output "echo Vid\\éos" + "Vidéos\n"))) (ert-deftest eshell-test/escape-nonspecial-quoted () "Test that the backslash is preserved for escaped nonspecial chars" (with-temp-eshell - (eshell-command-result-p "echo \"h\\i\"" - ;; Backslashes are doubled for regexp. - "h\\\\i\n"))) + (eshell-match-command-output "echo \"h\\i\"" + ;; Backslashes are doubled for regexp. + "h\\\\i\n"))) (ert-deftest eshell-test/escape-special-quoted () "Test that the backslash is not preserved for escaped special chars" (with-temp-eshell - (eshell-command-result-p "echo \"\\\"hi\\\\\"" - ;; Backslashes are doubled for regexp. - "\\\"hi\\\\\n"))) + (eshell-match-command-output "echo \"\\\"hi\\\\\"" + ;; Backslashes are doubled for regexp. + "\\\"hi\\\\\n"))) (ert-deftest eshell-test/command-running-p () "Modeline should show no command running" @@ -188,15 +188,15 @@ chars" (> count 0)) (sit-for 1) (setq count (1- count)))) - (eshell-match-result "alpha\n"))) + (should (eshell-match-output "alpha\n")))) (ert-deftest eshell-test/flush-output () "Test flushing of previous output" (with-temp-eshell (eshell-insert-command "echo alpha") (eshell-kill-output) - (eshell-match-result - (concat "^" (regexp-quote "*** output flushed ***\n") "$")))) + (should (eshell-match-output + (concat "^" (regexp-quote "*** output flushed ***\n") "$"))))) (ert-deftest eshell-test/run-old-command () "Re-run an old command" commit 1973d4ac1b613bdd6c70e1ef2bac97b538fbb2ed Author: Po Lu Date: Tue Aug 16 09:30:08 2022 +0800 Avoid lowering child frames below scroll bars on X * src/xterm.c (x_lower_frame_1): New function. (x_lower_frame): Avoid calling XLowerFrame when there is a parent with scroll bars. diff --git a/src/xterm.c b/src/xterm.c index 7b316ca9dd..ee0035234b 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -26167,18 +26167,52 @@ x_raise_frame (struct frame *f) unblock_input (); } +static void +x_lower_frame_1 (struct frame *f) +{ + Window *windows; + Lisp_Object frame, tail; + struct frame *sibling; + + windows = alloca (2 * sizeof *windows); + + /* Lowering a child frame leads to the window being put below any + scroll bars on the parent. To avoid that, restack the child + frame below all of its siblings instead of just lowering it. */ + + FOR_EACH_FRAME (tail, frame) + { + sibling = XFRAME (frame); + + if (sibling == f) + continue; + + if (FRAME_PARENT_FRAME (sibling) + != FRAME_PARENT_FRAME (f)) + continue; + + windows[0] = FRAME_OUTER_WINDOW (sibling); + windows[1] = FRAME_OUTER_WINDOW (f); + + XRestackWindows (FRAME_X_DISPLAY (f), windows, 2); + } +} + /* Lower frame F. */ static void x_lower_frame (struct frame *f) { - if (FRAME_VISIBLE_P (f)) - { - block_input (); - XLowerWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); - XFlush (FRAME_X_DISPLAY (f)); - unblock_input (); - } + if (FRAME_PARENT_FRAME (f) + && (FRAME_HAS_VERTICAL_SCROLL_BARS (FRAME_PARENT_FRAME (f)) + || FRAME_HAS_HORIZONTAL_SCROLL_BARS (FRAME_PARENT_FRAME (f)))) + x_lower_frame_1 (f); + else + XLowerWindow (FRAME_X_DISPLAY (f), + FRAME_OUTER_WINDOW (f)); + + XFlush (FRAME_X_DISPLAY (f)); + #ifdef HAVE_XWIDGETS /* Make sure any X windows owned by xwidget views of the parent still display below the lowered frame. */ commit f73d4d86f83645695200b018022e3a0fdd32ddad Author: Stefan Kangas Date: Tue Aug 16 02:39:27 2022 +0200 * doc/misc/gnus.texi (Troubleshooting): Update section. diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index a54afd9ea4..fd0825bfaa 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -29639,19 +29639,6 @@ Ahem. @item Make sure your computer is switched on. -@item -Make sure that you really load the current Gnus version. If you have -been running @sc{gnus}, you need to exit Emacs and start it up again before -Gnus will work. - -@item -Try doing an @kbd{M-x gnus-version}. If you get something that looks -like @c -@samp{Gnus v5.13} @c Adjust ../Makefile.in if you change this line! -@c -you have the right files loaded. Otherwise you have some old @file{.el} -files lying around. Delete these. - @item Read the help group (@kbd{G h} in the group buffer) for a @acronym{FAQ} and a how-to. @@ -29660,7 +29647,7 @@ Read the help group (@kbd{G h} in the group buffer) for a @vindex max-lisp-eval-depth Gnus works on many recursive structures, and in some extreme (and very rare) cases Gnus may recurse down ``too deeply'' and Emacs will beep at -you. If this happens to you, set @code{max-lisp-eval-depth} to 500 or +you. If this happens to you, set @code{max-lisp-eval-depth} to 2000 or something like that. @end enumerate @@ -29671,10 +29658,9 @@ If all else fails, report the problem as a bug. @findex gnus-bug If you find a bug in Gnus, you can report it with the @kbd{M-x -gnus-bug} command. @kbd{M-x set-variable @key{RET} debug-on-error -@key{RET} t @key{RET}}, and send me the backtrace. I will fix bugs, -but I can only fix them if you send me a precise description as to how -to reproduce the bug. +gnus-bug} command. @kbd{M-x toggle-debug-on-error}, and send me the +backtrace. I will fix bugs, but I can only fix them if you send me a +precise description as to how to reproduce the bug. You really can never be too detailed in a bug report. Always use the @kbd{M-x gnus-bug} command when you make bug reports, even if it creates @@ -29705,7 +29691,7 @@ edebug. Debugging Lisp code is documented in the Elisp manual (@pxref{Debugging, , Debugging Lisp Programs, elisp, The GNU Emacs Lisp Reference Manual}). To get you started with edebug, consider if you discover some weird behavior when pressing @kbd{c}, the first -step is to do @kbd{C-h k c} and click on the hyperlink (Emacs only) in +step is to do @kbd{C-h k c} and click on the hyperlink in the documentation buffer that leads you to the function definition, then press @kbd{M-x edebug-defun @key{RET}} with point inside that function, return to Gnus and press @kbd{c} to invoke the code. You will be @@ -29717,7 +29703,7 @@ evaluate expressions using @kbd{M-:} or inspect variables using @cindex elp @cindex profile @cindex slow -Sometimes, a problem do not directly generate an elisp error but +Sometimes, a problem do not directly generate an Emacs Lisp error but manifests itself by causing Gnus to be very slow. In these cases, you can use @kbd{M-x toggle-debug-on-quit} and press @kbd{C-g} when things are slow, and then try to analyze the backtrace (repeating the procedure commit 6e628ff99c3b55a74f3f34aed232ce8a1746aa27 Author: Stefan Monnier Date: Mon Aug 15 18:45:58 2022 -0400 * doc/lispref/functions.texi (What Is a Function): Improve further diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index ddf7cff6c2..983dfe2ec5 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -219,10 +219,12 @@ function. For example: @defun compiled-function-p object This function returns @code{t} if @var{object} is a function object -that was either built-in (a.k.a.@: ``primitive'', @pxref{What Is a -Function}), or byte-compiled (@pxref{Byte Compilation}), or -natively-compiled (@pxref{Native Compilation}), or a function loaded -from a dynamic module (@pxref{Dynamic Modules}). +that is not in the form of ELisp source code but something like +machine code or byte code instead. More specifically it returns +@code{t} if the function is built-in (a.k.a.@: ``primitive'', +@pxref{What Is a Function}), or byte-compiled (@pxref{Byte +Compilation}), or natively-compiled (@pxref{Native Compilation}), or +a function loaded from a dynamic module (@pxref{Dynamic Modules}). @end defun @defun subr-arity subr commit 82635f40ed4274a0bc372351902ff1cdef6dff23 Author: Eli Zaretskii Date: Mon Aug 15 22:12:58 2022 +0300 Produce TAGS in 'lib' as well and include them in src/TAGS * src/Makefile.in (TAGS): Include ../lib/TAGS. ($(lib)/TAGS): New target. (tags): Depend on $(lib)/TAGS. diff --git a/src/Makefile.in b/src/Makefile.in index a7024bda46..1f941874ea 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -790,11 +790,12 @@ ctagsfiles3 = $(wildcard ${srcdir}/*.cc) ## In out-of-tree builds, TAGS are generated in the build dir, like ## other non-bootstrap build products (see Bug#31744). -## This does not need to depend on ../lisp and ../lwlib TAGS files, +## This does not need to depend on ../lisp, ../lwlib and ../lib TAGS files, ## because etags "--include" only includes a pointer to the file, ## rather than the file contents. TAGS: ${ETAGS} $(ctagsfiles1) $(ctagsfiles2) $(AM_V_GEN)${ETAGS} --include=../lisp/TAGS --include=$(lwlibdir)/TAGS \ + --include=$(lib)/TAGS \ --regex='{c}/[ ]*DEFVAR_[A-Z_ (]+"\([^"]+\)"/\1/' \ --regex='{c}/[ ]*DEFVAR_[A-Z_ (]+"[^"]+",[ ]\([A-Za-z0-9_]+\)/\1/' \ $(ctagsfiles1) \ @@ -803,12 +804,12 @@ TAGS: ${ETAGS} $(ctagsfiles1) $(ctagsfiles2) $(ctagsfiles2) \ $(ctagsfiles3) -## Arrange to make tags tables for ../lisp and ../lwlib, +## Arrange to make tags tables for ../lisp, ../lwlib and ../lib, ## which the above TAGS file for the C files includes by reference. -../lisp/TAGS $(lwlibdir)/TAGS: FORCE +../lisp/TAGS $(lwlibdir)/TAGS $(lib)/TAGS: FORCE $(MAKE) -C $(dir $@) $(notdir $@) ETAGS="$(ETAGS)" -tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS +tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS $(lib)/TAGS .PHONY: tags commit 9ea40b3ddfba1104d02ff61e3d20482287d3caca Author: Michael Albinus Date: Mon Aug 15 19:35:43 2022 +0200 Fix tmpdir handling in Tramp for Android sshd * doc/misc/tramp.texi (Android shell setup): Rework. * lisp/net/tramp.el (tramp-get-remote-tmpdir): Cache result in temporary connection property. diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 924aa66d44..96ffb5c880 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -2975,14 +2975,31 @@ where @samp{192.168.0.26} is the Android device's IP address. (@pxref{Predefined connection information}). @item -@value{tramp} requires preserving @env{PATH} environment variable from -user settings. Android devices prefer @file{/system/xbin} path over -@file{/system/bin}. Both of these are set as follows: +On the Android device the directory names are prefixed with an +application specific prefix, which is +@file{/data/data/com.termux/files/usr/bin} instead of @file{/usr/bin} +in the @code{Termux} case. You must adapt the file names in +@code{tramp-remote-path}, for example via connection-local +@ifinfo +settings (@pxref{Connection Variables, , , emacs}): +@end ifinfo +@ifnotinfo +settings: +@end ifnotinfo @lisp @group -(add-to-list 'tramp-remote-path 'tramp-own-remote-path) -(add-to-list 'tramp-remote-path "/system/xbin") +(connection-local-set-profile-variables + 'tramp-connection-local-termux-profile + `((tramp-remote-path + . ,(mapcar + (lambda (x) + (if (stringp x) (concat "/data/data/com.termux/files" x) x)) + (copy-tree tramp-remote-path))))) + +(connection-local-set-profiles + '(:application tramp :machine "192.168.0.26") + 'tramp-connection-local-termux-profile) @end group @end lisp @@ -2991,7 +3008,9 @@ When the Android device is not @samp{rooted}, specify a writable directory for temporary files: @lisp -(add-to-list 'tramp-remote-process-environment "TMPDIR=$HOME") +(add-to-list 'tramp-connection-properties + (list (regexp-quote "192.168.0.26") + "tmpdir" "/data/data/com.termux/files/home/tmp")) @end lisp @item @@ -3019,11 +3038,17 @@ the previous example, fix the connection properties as follows: @group (add-to-list 'tramp-connection-properties (list (regexp-quote "android") "remote-shell" "sh")) +(add-to-list 'tramp-connection-properties + (list (regexp-quote "android") + "tmpdir" "/data/data/com.termux/files/home/tmp")) +(connection-local-set-profiles + '(:application tramp :machine "android") + 'tramp-connection-local-termux-profile) @end group @end lisp @noindent -Open a remote connection with a more concise command @kbd{C-x C-f +Open a remote connection with the more concise command @kbd{C-x C-f @trampfn{ssh,android,} @key{RET}}. @end itemize diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 4cc4ee0722..5ffc4f1b88 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -6011,7 +6011,7 @@ This handles also chrooted environments, which are not regarded as local." (defun tramp-get-remote-tmpdir (vec) "Return directory for temporary files on the remote host identified by VEC." - (with-tramp-connection-property vec "tmpdir" + (with-tramp-connection-property (tramp-get-process vec) "remote-tmpdir" (let ((dir (tramp-make-tramp-file-name vec (or (tramp-get-method-parameter vec 'tramp-tmpdir) "/tmp")))) commit d5e74d9cd7fd657f13ef7ac72cf84c3bc3a03ba9 Author: Lars Ingebrigtsen Date: Mon Aug 15 17:08:25 2022 +0200 Clean up message-sort-headers code slightly * lisp/gnus/message.el (message-sort-headers): Simplify code by removing always-true `if' statement. diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 8a3967f346..90d8a744de 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -2732,20 +2732,17 @@ Point is left at the beginning of the narrowed-to region." (interactive nil message-mode) (save-excursion (save-restriction - (let ((max (1+ (length message-header-format-alist))) - rank) + (let ((max (1+ (length message-header-format-alist)))) (message-narrow-to-headers) (while (re-search-forward "^[^ \n]+:" nil t) (put-text-property (match-beginning 0) (1+ (match-beginning 0)) 'message-rank - (if (setq rank (length (memq (assq (intern (buffer-substring - (match-beginning 0) - (1- (match-end 0)))) - message-header-format-alist) - message-header-format-alist))) - (- max rank) - (1+ max))))) + (- max (length + (memq (assq (intern (buffer-substring + (match-beginning 0) (1- (match-end 0)))) + message-header-format-alist) + message-header-format-alist)))))) (message-sort-headers-1)))) (defun message-kill-address () commit 0d3aebec0141ab57362477c50065222a03d57c08 Author: kobarity Date: Mon Aug 15 16:30:23 2022 +0200 Fix `python-nav-forward-block' moving backward under certain conditions * lisp/progmodes/python.el (python-nav-forward-block): Add check for not moving backward (bug#57223). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 96f9d14832..44df3186b2 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1822,7 +1822,8 @@ backward to previous block." (or arg (setq arg 1)) (let ((block-start-regexp (python-rx line-start (* whitespace) block-start)) - (starting-pos (point))) + (starting-pos (point)) + (orig-arg arg)) (while (> arg 0) (python-nav-end-of-statement) (while (and @@ -1836,7 +1837,8 @@ backward to previous block." (python-syntax-context-type))) (setq arg (1+ arg))) (python-nav-beginning-of-statement) - (if (not (looking-at (python-rx block-start))) + (if (or (and (> orig-arg 0) (< (point) starting-pos)) + (not (looking-at (python-rx block-start)))) (and (goto-char starting-pos) nil) (and (not (= (point) starting-pos)) (point-marker))))) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index d303050fad..9e8fa7f552 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -2942,6 +2942,22 @@ if request.user.is_authenticated(): (python-tests-look-at "if request.user.is_authenticated():" -1))))) +(ert-deftest python-nav-forward-block-2 () + (python-tests-with-temp-buffer + " +if True: + pass +" + (python-tests-look-at "if True:") + (should (not (save-excursion (python-nav-forward-block)))) + (should (not (save-excursion (python-nav-forward-block -1)))) + (forward-char) + (should (not (save-excursion (python-nav-forward-block)))) + (should (= (save-excursion (python-nav-forward-block -1)) + (progn + (end-of-line) + (python-tests-look-at "if True:" -1)))))) + (ert-deftest python-nav-forward-sexp-1 () (python-tests-with-temp-buffer " commit 5025b2566e72ba37b62c2a00feef46268fc9f468 Author: Lars Ingebrigtsen Date: Mon Aug 15 16:18:21 2022 +0200 Fix fix_command for non-symbol functions * src/callint.c (fix_command): Don't bug out on commands that aren't symbols (like lambdas, for instance). diff --git a/src/callint.c b/src/callint.c index c974967459..8ef0e5240a 100644 --- a/src/callint.c +++ b/src/callint.c @@ -171,7 +171,7 @@ static void fix_command (Lisp_Object function, Lisp_Object values) { /* Quick exit if there's no values to alter. */ - if (!CONSP (values)) + if (!CONSP (values) || !SYMBOLP (function)) return; Lisp_Object reps = Fget (function, Qinteractive_args); commit 629f980fad0bee97ff63c5f684b472cc71061eea Author: Alan Mackenzie Date: Mon Aug 15 12:18:01 2022 +0000 Enhance safe_run_hooks_1 and safe_run_hook_funcall to handle more arguments This fixes bug #57179. * src/keyboard.c (safe_run_hooks_1, safe_run_hook_funcall): Enhance these functions so that nargs == 3 or 4 is handled as well as nargs == 2. This allows them to be used to call hooks with 1 or 2 arguments. diff --git a/src/keyboard.c b/src/keyboard.c index 8a2b7d58c4..1d7125a0a3 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1832,8 +1832,16 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified) static Lisp_Object safe_run_hooks_1 (ptrdiff_t nargs, Lisp_Object *args) { - eassert (nargs == 2); - return call0 (args[1]); + eassert (nargs >= 2 && nargs <= 4); + switch (nargs) + { + case 2: + return call0 (args[1]); + case 3: + return call1 (args[1], args[2]); + default: + return call2 (args[1], args[2], args[3]); + } } /* Subroutine for safe_run_hooks: handle an error by clearing out the function @@ -1878,11 +1886,27 @@ safe_run_hooks_error (Lisp_Object error, ptrdiff_t nargs, Lisp_Object *args) static Lisp_Object safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args) { - eassert (nargs == 2); + eassert (nargs >= 2 && nargs <= 4); /* Yes, run_hook_with_args works with args in the other order. */ - internal_condition_case_n (safe_run_hooks_1, - 2, ((Lisp_Object []) {args[1], args[0]}), - Qt, safe_run_hooks_error); + switch (nargs) + { + case 2: + internal_condition_case_n (safe_run_hooks_1, + 2, ((Lisp_Object []) {args[1], args[0]}), + Qt, safe_run_hooks_error); + break; + case 3: + internal_condition_case_n (safe_run_hooks_1, + 3, ((Lisp_Object []) {args[1], args[0], args[2]}), + Qt, safe_run_hooks_error); + break; + default: + internal_condition_case_n (safe_run_hooks_1, + 4, ((Lisp_Object []) + {args[1], args[0], args[2], args[3]}), + Qt, safe_run_hooks_error); + break; + } return Qnil; } commit d5ee49c25c8f59ab17c40eebdf38a769c2f5588b Author: Yury Kholodkov Date: Mon Aug 15 09:36:06 2022 +0200 Fix variable types in warnings-suppress * lisp/emacs-lisp/warnings.el (warnings-suppress): The type of these user options is a list of lists of symbols, not a list of symbols (bug#57183). Copyright-paperwork-exempt: yes diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el index d60eedbc9c..3a966957ec 100644 --- a/lisp/emacs-lisp/warnings.el +++ b/lisp/emacs-lisp/warnings.el @@ -220,10 +220,10 @@ SUPPRESS-LIST is the list of kinds of warnings to suppress." (?q "quit and do nothing")))) (?y (customize-save-variable 'warning-suppress-log-types - (cons type warning-suppress-log-types))) + (cons (list type) warning-suppress-log-types))) (?n (customize-save-variable 'warning-suppress-types - (cons type warning-suppress-types))) + (cons (list type) warning-suppress-types))) (_ (message "Exiting")))) ;;;###autoload commit 20b8ac5723661de8920c0090fe91368d3229723c Author: Lars Ingebrigtsen Date: Mon Aug 15 09:27:13 2022 +0200 Make eshell-mode more resilient towards `mode-line-format' * lisp/eshell/esh-mode.el (eshell-mode): `mode-line-format' can be a string (bug#57185). In that case, don't alter anything. diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 972d4f9df0..ecbcf88b97 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -301,7 +301,8 @@ and the hook `eshell-exit-hook'." "Emacs shell interactive mode." (setq-local eshell-mode t) - (when eshell-status-in-mode-line + (when (and eshell-status-in-mode-line + (listp mode-line-format)) (make-local-variable 'eshell-command-running-string) (let ((fmt (copy-sequence mode-line-format))) (setq-local mode-line-format fmt))