To factorize code of test sets (or not)
* [2025-01-07 19:38] Ihor Radchenko:> Phil Estival writes: [...] Some macros [for test suite] should probably be moved upward in a file where generic functions which purposes are to help writing the tests of babel source blocks should be declared. I do not mind. But please show which _other_ tests can benefit from the simplification. This may appear as an unnecessary effort to refactor, or worse, normalize a code that can benefit from some diversity yet, the forms (should (equal "" (org-test-with-temp-text "" (org-babel-next-src-block) (org-trim (org-babel-execute-src-block)) or (org-test-with-temp-text "" (org-babel-next-src-block) (should (equal '() ;; or (should (string= " (org-babel-execute-src-block ;; or org-babel-execute-maybe for ruby and elisp exist in test-ob-[maxima,R,sqlite,sed,shell,plantuml,lua,java,julia,lob,octave,perl,python,emacs-lisp].el Considering it at the repetitive pattern, I think a macro can shorten those forms to : (ob-test "" :expect "") and a variant to test or exclude matching regexp (ob-test "" :expect-to-match "") (ob-test "" :expect-to-not-match "") IMHO, they would be easier to read with one additional line feed (ob-test " #+begin_src ... #+end_src" :expect "") rather than (ob-test "#+begin_src ... #+end_src" :expect "") Similar macro/function exists in ob-emacs-lisp/dynamic-lexical-execute or ob-sql/command-should-contain. my 2¢, Phil
[BUG][minor] org-mouse
Org-mouse makes a star followed by a blank space clickable anywhere, also in source blocks and this triggers the evaluation of the block or the opening of *Org-Babel Error Output* or *Org Babel Results*. emacs -q org mode v 9.8-pre file:/tmp/test-org-mouse.org (require 'org-mouse) (require 'warnings) #+begin_src bash echo "Where is Charlie?" #* <-clicking the star... #+end_src ...will asks for the evaluation of the block or reopen the result buffer. Additionally, I got puzzled by the end of the following sequence. (org-babel-do-load-languages 'org-babel-load-languages '((shell . t))) and click the star again evaluate this bash block on your system ? this time evaluates, and opens *Org Babel Results* with the previous results. If it's clicked once more, it opens again *Org Babel Results* without running the source (changing the source block, killing the result buffer and clicking again confirms that). At this point, I'm confused because this result buffer is also reloaded after a fresh session of emacs -q ... but I don't know where to look for its source (rg --hidden Charlie) in /tmp or ~/.emacs or org-persist-directory? In this case please tell me, where is Charlie? Phil
31.0.50; Fontification malfunction
Originally sent to bug-gnu-emacs but was asked to file as an Org bug: --text follows this line-- - Start emacs: 'emacs -Q' - Paste this function into the scratch buffer and evaluate it: (defun test-org-insertion-fontification () (interactive) (let* ((chunks '("#+begin_src elisp\n" "(+ 1 2)" "\n#+end_src\n"))) (insert "* NOTE: You need to run this with org-mode enabled and point at end of buffer\n\n") (insert "** This code block is fontified correctly\n") (insert (car chunks)) (dolist (chunk (cdr chunks)) (insert chunk)) (insert "\n** But not this code block\n") (insert (car chunks)) (dolist (chunk (cdr chunks)) (sit-for (/ 10 1000.0)) ; simulate chunks received over network and streamed into buffer ;; The following were also tested one by one instead of the sit-for line above: ;; (redisplay) ; this triggers the bug ;; (force-mode-line-update) ; this does not trigger the bug ;; (read-event nil nil 0) ; this triggers the bug (insert chunk)) )) - Open an existing or new file/buffer with org-mode enabled (C-x C-f foo.org ) - Place point at end of buffer - M-x test-org-insertion-fontification - Optional: replace the line (sit-for...) with any of the lines below it. - Additional information: The problem was discovered when receiving streamed data responses via the package gptel which is an Emacs LLM Client. Here is the reported issue: https://github.com/karthink/gptel/issues/550 - Also replicated on Emacs 29.3 In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2025-01-07 built on piano Repository revision: 4bf0f6655142b9e216325d051943b7b7ca4d2cd7 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Linux Mint 21.3 Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB Important settings: value of $LC_MONETARY: sv_SE.UTF-8 value of $LC_NUMERIC: sv_SE.UTF-8 value of $LC_TIME: en_GB.UTF-8 value of $LANG: C.UTF-8 locale-coding-system: utf-8-unix Major mode: Org Minor modes in effect: tooltip-mode: t global-eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t minibuffer-regexp-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug face-remap help-macro oc-basic cl-extra help-mode org-element org-persist org-id org-refile org-element-ast inline avl-tree generator ol-eww eww vtable mule-util url-queue mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig gnus-sum shr pixel-fill kinsoku url-file svg dom gnus-group gnus-undo gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail browse-url xdg url url-proxy url-privacy url-expand url-methods url-history url-cookie generate-lisp-file url-domsuf url-util url-parse auth-source cl-seq eieio eieio-core cl-macs json map url-vars mail-source utf7 nnoo parse-time gnus-spec gnus-int gnus-range message sendmail mailcap yank-media puny rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util text-property-search mail-utils range mm-util mail-prsvr wid-edit ol-docview doc-view byte-opt gv bytecomp byte-compile filenotify jka-compr image-mode exif dired dired-loaddefs ol-bibtex bibtex iso8601 ol-bbdb ol-w3m ol-doi org-link-doi org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src sh-script smie treesit executable ob-comint org-pcomplete pcomplete comint ansi-osc ansi-color ring org-list org-footnote org-faces org-entities time-date subr-x noutline outline icons org-version ob-emacs-lisp ob-core ob-eval org-cycle org-table ol rx org-fold org-fold-core org-keys oc org-loaddefs thingatpt find-func cal-menu calendar cal-loaddefs org-compat org-macs format-spec cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvi
Re: Org-protocol browser extensions avoiding use of bookmarklets
On 08/01/2025 01:14, Rehan Deen wrote: I just came across this extension: https://www.reddit.com/r/emacs/comments/1hvtlsa/the_new_and_only_orgprotocol_chrome_extension_you/ https://addons.mozilla.org/en-US/firefox/addon/emacs-paw/ Do you think this meets some of your needs and avoids the security issues you've raised? The code has not been published yet and I have no motivation to extract it from the .xpi file. I have not tried it in action since I am not inspired by the description. I do not like popups over page text. My extension is not ideal, but it covers my use case (quite different from "paw"). In Firefox, the add-on likely request permission for an org-protocol handler on behalf of itself and it is OK. In Chrome it depends on API used by the extension. I am against granting the permission to web sites, in addition it is annoying to confirm intention for every site. Ideally, extension should escape characters in page titles and selected text that may be considered as Org markup. Otherwise there is a chance to unintentionally execute some code. It requires some user interaction, but e.g. TAB is used too often. As to a bug for changed bookmarklet behavior in Firefox, there is almost no chance that I will file it since I do not use this feature.
Re: test-org-table/sort-lines: Failing test on macOS
On Mon, Jan 6, 2025 at 9:49 PM Michael Brand wrote: > My patch _neutralizes_ the ignore case behavior of ~string-collate-lessp~. The attached patches implement this suggestion and are applicable on bugfix and main. Tested with Emacs 29.4 of Homebrew on macOS. Please review and if someone can test the final version also on Linux and Windows I suggest to apply on bugfix. From c14d387343e4cb20fe3018fbe991797d20a9f29f Mon Sep 17 00:00:00 2001 From: Michael Brand Date: Wed, 8 Jan 2025 17:47:14 +0100 Subject: [PATCH 1/2] Align test with other tests * testing/lisp/test-org-table.el (test-org-table/sort-lines): `(org-table-sort-lines nil ?A)' is already tested, change it to the missing `(org-table-sort-lines t ?A)'. --- testing/lisp/test-org-table.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index df63a65fc..cfc8e2a0b 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -1908,6 +1908,7 @@ See also `test-org-table/copy-field'." (lambda (s1 s2 &optional _locale ignore-case) (funcall original-string-collate-lessp s1 s2 "C" ignore-case + ;; Sort alphabetically ignore case. (should (equal "| a | x |\n| B | 4 |\n| c | 3 |\n" (org-test-with-temp-text "| a | x |\n| c | 3 |\n| B | 4 |\n" @@ -1925,9 +1926,9 @@ See also `test-org-table/copy-field'." (org-table-sort-lines t ?a) (buffer-string (should - (equal "| C |\n| b |\n| a |\n" + (equal "| b |\n| a |\n| C |\n" (org-test-with-temp-text "| a |\n| C |\n| b |\n" - (org-table-sort-lines nil ?A) + (org-table-sort-lines t ?A) (buffer-string)) ;; Sort by time (timestamps) (should -- 2.39.3 (Apple Git-145) From 9aeafc6bc9209f56ce757f1ae9b600f804ec3ad7 Mon Sep 17 00:00:00 2001 From: Michael Brand Date: Wed, 8 Jan 2025 17:47:17 +0100 Subject: [PATCH 2/2] Fix test for when ignore case is not supported * testing/lisp/test-org-table.el (test-org-table/sort-lines): Fix test for when `string-collate-lessp' does not support ignore case. * testing/org-test.el (;;; Functions for writing tests): Add function `org-test-string-collate-lessp-ignore-case-supported-p'. In the context of the `cl-letf' of `test-org-table/sort-lines' the new `org-test-string-collate-lessp-ignore-case-supported-p' evaluates to nil with Emacs 29.4 of Homebrew on macOS. --- testing/lisp/test-org-table.el | 8 ++-- testing/org-test.el| 13 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index cfc8e2a0b..3e75d506e 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -1910,12 +1910,16 @@ See also `test-org-table/copy-field'." s1 s2 "C" ignore-case ;; Sort alphabetically ignore case. (should - (equal "| a | x |\n| B | 4 |\n| c | 3 |\n" + (equal (if (org-test-string-collate-lessp-ignore-case-supported-p) + "| a | x |\n| B | 4 |\n| c | 3 |\n" +"| B | 4 |\n| a | x |\n| c | 3 |\n") (org-test-with-temp-text "| a | x |\n| c | 3 |\n| B | 4 |\n" (org-table-sort-lines nil ?a) (buffer-string (should - (equal "| c | 3 |\n| B | 4 |\n| a | x |\n" + (equal (if (org-test-string-collate-lessp-ignore-case-supported-p) + "| c | 3 |\n| B | 4 |\n| a | x |\n" +"| c | 3 |\n| a | x |\n| B | 4 |\n") (org-test-with-temp-text "| a | x |\n| c | 3 |\n| B | 4 |\n" (org-table-sort-lines nil ?A) (buffer-string diff --git a/testing/org-test.el b/testing/org-test.el index 643c5c766..99d5f7c4a 100644 --- a/testing/org-test.el +++ b/testing/org-test.el @@ -309,6 +309,19 @@ Tramp related features. We mostly follow (declare (debug (sexp body)) (indent 2)) `(org-test-with-tramp-remote-dir--worker (lambda (,dir) ,@body))) +(defun org-test-string-collate-lessp-ignore-case-supported-p +(&optional locale) + "`string-collate-lessp' supports ignore case for LOCALE. +According to the docstring of `string-collate-lessp' it does not +implement ignore case for some locale on some operating systems, +actually depending on libc of Emacs. `string-collate-lessp' +ignores when its parameter IGNORE-CASE is non-nil e. g. for the C +locale in Emacs 29.4 of Homebrew on macOS. + +See also https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59275 and +https://list.orgmode.org/orgmode/m2ilkwso8r.fsf@me.com"; + (let ((ignore-case t)) +(string-collate-lessp "a" "B" locale ignore-case))) ;;; Navigation Functions -- 2.39.3 (Apple Git-145)