[BUG] org-edit-special is not working with korean characters [9.6.6 (release_9.6.6 @ /home/sukbeom/opt/share/emacs/29.1/lisp/org/)]

2023-11-11 Thread sukbeom . kim
Hi,

I found that there is a bug with typing Korean characters with table.el
table.

At first, I thought this was related to the Emacs's overwrite-mode issue
(https://debbugs.gnu.org/cgi/bugreport.cgi?bug=66970), but it still not
be resolved even after applying the workaround patch.

The thing is, whenever I type korean characters within the table.el
table, it just inserts characters, breaking the table.

+--+--+---+
|First row |Japanese  |Korean |
+--+--+---+
|Test #1   |あえいおう|아에   | <- expected
+--+--+---+
|Test #1   |あえいおう|아에   | <- actual behavior
+--+--+---+

The test sequence is,

1. Create a table.

| First row | Japanese | Korean |
| Test #1   |  ||
| Test #2   |  ||

2. Convert the table to table.el table. (C-c ~)
+---+--+-+
| First row | Japanese |  Korean |
+---+--+-+
| Test #1   |  | |
+---+--+-+
| Test #2   |  | |
+---+--+-+

3. Try to type characters
-  set-input-method
 -> japanese-hiragana
  -> aeiou => あえいおう
 -> korean-hangul
  -> dkdp => 아에

I use 'D2Coding' font to prevent Emacs from printing characters
unaligned between alphabets and CJK characters. And I found that this
issue is only reproduced within Korean characters, not other
Japanese/Chinese characters.


Emacs  : GNU Emacs 29.1 (build 14, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, 
cairo version 1.16.0)
 of 2023-09-18
Package: Org mode version 9.6.6 (release_9.6.6 @ 
/home/sukbeom/opt/share/emacs/29.1/lisp/org/)

current state:
==
(setq
 org-link-elisp-confirm-function 'yes-or-no-p
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-persist-after-read-hook '(org-element--cache-persist-after-read)
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-cycle-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines
  org-cycle-optimize-window-after-visibility-change 
org-cycle-display-inline-images)
 org-persist-before-read-hook '(org-element--cache-persist-before-read)
 org-mode-hook '(#[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-fold-show-all append 
local] 5]
 #[0 "\300\301\302\303\304$\207"
   [add-hook change-major-mode-hook org-babel-show-result-all 
append local] 5]
 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-confirm-shell-link-function 'yes-or-no-p
 outline-isearch-open-invisible-function 'outline-isearch-open-invisible
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
org-src-mode-configure-edit-buffer)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-speed-command-hook '(org-speed-command-activate 
org-babel-speed-command-activate)
 org-persist-directory "/tmp/org-persist-a4oJE0"
 org-fold-core-isearch-open-function 'org-fold--isearch-reveal
 org-persist-before-write-hook '(org-element--cache-persist-before-write)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
org-babel-header-arg-expand)
 org-link-shell-confirm-function 'yes-or-no-p
 org-babel-pre-tangle-hook '(save-buffer)
 org-agenda-loop-over-headlines-in-active-region nil
 org-occur-hook '(org-first-headline-recenter)
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-link-parameters '(("attachment" :follow org-attach-follow :complete 
org-attach-complete-link)
   ("id" :follow org-id-open)
   ("eww" :follow org-eww-open :store org-eww-store-link)
   ("rmail" :follow org-rmail-open :store 
org-rmail-store-link)
   ("mhe" :follow org-mhe-open :store org-mhe-store-link)
   ("irc" :follow org-irc-visit :store org-irc-store-link 
:export org-irc-export)
   ("info" :follow org-info-open :export org-info-export 
:store
org-info-store-link :insert-description 
org-info-description-as-command)
   ("gnus" :follow org-gnus-open :store org-gnus-store-link)
   ("docview" :follow org-docview-open :export 
org-docview-export :store
org-docview-store-link)
   ("bibtex" :follow org-bibtex-open :store 
org-bibtex-store-link)
   ("bbdb" :follow org-bbdb-open :export org-bbdb-export 
:complete
org-bbdb-complete-link :store org-bbdb-store-link)
   ("w3m" :store org-w3m-store-link)
   ("doi" :follow org-link-doi-open :export 
org-link-doi-export) ("file+sys")
   ("file+emacs") ("shell" :follow 

Re: Issue with org-persist and Tramp

2023-11-11 Thread Fabio Natali
On 2023-11-11, 11:06 +, Ihor Radchenko  wrote:
> Fixed, on bugfix.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=866e638c2

Super, thanks for helping with this, Ihor. 

> You may consider customizing `remote-file-name-inhibit-locks'.

Ah! Good to know, thanks.

Cheers, F.



Links & images with different attributes in the same paragraph

2023-11-11 Thread Max Nikulin

Hi,

I raised this topic earlier. It seems, there is a rather generic 
workaround that may help.


Sometimes it is necessary to assign specific export attributes to some 
links in a paragraph while others should get another set of them. Inline 
images should have different alt text.


--- 8< ---
Text with <> in a paragraph.

Any link types are supported including
[[wrap::href "anchor"][internal]] ones.
Attributes may be added selectively:
https://microsoft.com/; :attr_html ":class external \
:title Link that does not increase target page rank \
:noreferrer 1" :attr_html ":nofollow 1 :noopener 1">

Images in the same paragraph may have different =alt= attribute:
raster
[[wrap::attr_html ":alt PNG Unicorn"
:href 
"https://orgmode.org/worg/images/orgmode/org-mode-unicorn-original-logo.png;]]

and vector
[[wrap::attr_html ":alt SVG Unicorn"
:href "https://orgmode.org/resources/img/org-mode-unicorn.svg;]]
images.
--- >8 ---

is exported as

--- 8< ---

Text with  in a paragraph.



Any link types are supported including
internal ones.
Attributes may be added selectively:
https://microsoft.com/; class="external" title="Link that does 
not increase target page rank" noreferrer="1" nofollow="1" 
noopener="1">https://microsoft.com/




Images in the same paragraph may have different alt attribute:
raster
src="https://orgmode.org/worg/images/orgmode/org-mode-unicorn-original-logo.png; 
alt="PNG Unicorn" />

and vector
https://orgmode.org/resources/img/org-mode-unicorn.svg; 
alt="SVG Unicorn" class="org-svg" />

images.

--- >8 ---

and it requires not so much code:

# #+header: :eval never-export
#+begin_src elisp :exports results :results silent
  (defun nm/org-link-wrap-path-to-props (path)
(read (concat "(" path ")")))

  (defun nm/org-link-wrap-copy-props (props link)
(while props
  (let ((name (pop props))
  (value (pop props))
  (case-fold-search t))
(org-element-put-property
 link
 name
 ;; `org-element--collect-affiliated-keywords'
 (if (string-match-p "\\`:attr_" (symbol-name name))
   (append (org-element-property name link) (list value))
 value)

  (defun nm/org-link-wrap-export
  (path description backend info)
(let* ((props-all (nm/org-link-wrap-path-to-props path))
 (href (plist-get props-all :href))
 ;; `org-plist-delete' removes other duplicated keys as well.
 (props (map-delete props-all :href))
 ;; Taken from `org-link-open-from-string'.
 (link (with-temp-buffer
 (let ((org-inhibit-startup nil))
   (insert "[[" (org-link-escape href) "]]")
   (org-mode)
   (goto-char (point-min))
   (org-element-link-parser)
  (nm/org-link-wrap-copy-props props link)
  (when description
(org-element-set-contents link description))
  (org-no-properties
   (org-export-data-with-backend link backend info

  (defun nm/org-link-wrap-follow (path arg)
(let* ((props (nm/org-link-wrap-path-to-props path))
 (href (plist-get props :href)))
  (org-link-open-from-string
   (concat "[[" (org-link-escape href) "]]")
   arg)))

  (org-link-set-parameters
   "wrap"
   :follow #'nm/org-link-wrap-follow
   :export #'nm/org-link-wrap-export)
#+end_src

An example of earlier discussion:
https://list.orgmode.org/t8q71r$mgv$1...@ciao.gmane.io/
Max Nikulin. [BUG] manual: confusing example of adding attributes to a 
link (affiliated keywords). Mon, 20 Jun 2022 23:25:29 +0700





Re: [RFC][PATCH v2] Allow to export to ascii custom link types as notes

2023-11-11 Thread Ihor Radchenko
Max Nikulin  writes:

> On 08/11/2023 18:16, Ihor Radchenko wrote:
>> We can introduce a special ox-ascii-specific object `object-with-note'
>> that will be exported by ox-ascii according to
>> `org-ascii-links-to-notes' settings. Then, we can transform link objects
>> into `object-with-note' that will later be used in
>> `org-ascii--describe-links'.
>
> I am in doubts if it is a bright idea to transform in place passed link 
> object inside `org-ascii-link'.

> I see 2 ways:
> - Use ad-hoc object-with-note org-element object instead of `cons' in my 
> patch (rather cosmetic change).
> - Introduce :filter property for links that is called before export 
> pass. These functions may return arbitrary elements instead of original 
> links. For ox-ascii a dedicated transcoder for object-with-note is 
> added. Only custom link types having :export property are processed by 
> `org-ascii-link'.

By "transform", I meant return `object-with-note'. Basically, the second
item in your list.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Issue with org-persist and Tramp

2023-11-11 Thread Ihor Radchenko
Fabio Natali  writes:

> Sorry for the delay. My results below, after testing a couple of
> different cases.
>
> If the remote file had been saved before losing connection, then the
> patch below will fix the problem. TRAMP will still hang for a while, as
> it tries to reach the server but the buffer will be closed immediately
> when using `tramp-cleanup-all-buffers' (or a variant thereof).
> ...
> (Apologies, the patch is badly formatted and not meant for the
> repository.) The gist is that I replaced an occurrence of `associated'
> with `file' in your latest patch, Ihor. It seems to work, what do you
> think?

I made the same change in my v2 patch.
Applied.
Fixed, on bugfix.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=866e638c2

> However, if the remote file hadn't been saved, then TRAMP will still
> hang indefinitely. Quitting will reveal the following backtrace:
>
> Debugger entered--Lisp error: (quit "")
> ...
>   tramp-file-name-handler(unlock-file "/ssh:192.168.1.100:~/test.org")
>   kill-buffer("test.org")
>   funcall-interactively(kill-buffer "test.org")
>   command-execute(kill-buffer)
>
> This seems to be on the TRAMP side?

Yes.
You may consider customizing `remote-file-name-inhibit-locks'.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] tmp [9.7-pre (release_9.6.10-881-g595a32 @ /home/ps/.emacs.d/org-mode-git/lisp/)]

2023-11-11 Thread Paul Stansell
Hello Ihor,

Thanks very much for your clarification and advice.  I didn't know about
C- or `org-fold-catch-invisible-edits'.  Setting

   (setq org-fold-catch-invisible-edits 'error)

is very useful.

Paul


Re: Replace org link with footnote

2023-11-11 Thread Ihor Radchenko
Matt  writes:

> ...  Maybe a fun first commit for someone would be to update 
> `org-footnote-new` to accept optional LABEL and DEFINITION arguments that 
> allow a footnote to be created programmatically?

I would not mind such a patch.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [TASK] Allow customizeable ditaa executable in ob-ditaa.el

2023-11-11 Thread Ihor Radchenko
Leo Butler  writes:

>> And even if we do want to add certain features in future (like
>> supporting ditaa executable herein), it does not mean that we have to
>> rush them by any cost.
>
> Ihor, I don't understand that sentence.
>
> The *documentation* patch was intended to show that ob-ditaa did not
> need to be changed. A user can already run ditaa from a script file by
> setting the customization variables appropriately (or, inappropriately,
> as Max said ;-) ).

Let me elaborate.
The below explanation in your patch relies upon the implementation
detail in `org-babel-execute:ditaa' - how the ditaa command is called.

 +First, set ~org-babel-ditaa-java-cmd~ and ~org-ditaa-jar-option~ to
 +empty strings and ~org-ditaa-jar-path~ to the script's path; here, it
 +is =/usr/bin/ditaa=.  This example uses ~setq-local~ to change only
 +the values in this buffer.
 +
 +#+NAME: hello-world-from-script.el.org
 +#+BEGIN_SRC org :exports code :results replace
 +,#+NAME: hello-world-from-script.el
 +,#+BEGIN_SRC emacs-lisp :exports none :results none
 +(setq-local org-babel-ditaa-java-cmd ""
 +  org-ditaa-jar-option ""
 +  org-ditaa-jar-path "/usr/bin/ditaa")
 +,#+END_SRC
 +#+END_SRC

however, it can easily happen that we change that detail in future.
In fact, your explanation is already not correct for
:file foo.eps - org-ditaa-jar-path value is ignored in such scenario:

(cmd (concat org-babel-ditaa-java-cmd
  " " java " " org-ditaa-jar-option " "
  (shell-quote-argument
   (expand-file-name
(if eps org-ditaa-eps-jar-path org-ditaa-jar-path)))
  " " cmdline
  " " (org-babel-process-file-name in-file)
  " " (if pdf-cmd
  eps-file
(org-babel-process-file-name out-file

Further, it won't help with the discussed problem -
trying
(setq org-ditaa-jar-path "flatpak-spawn --host toolbox run ditaa") will
simply fail when passed through `shell-quote-argument'.

And now imagine that we change how CMD is produced in future. (For
example, there is a WIP branch that unifies escaping command arguments
to avoid vulnerabilities). Your documentation patch may cease working
any moment, causing damage to users who tried to follow it. Or we may
have to constrain the ways we change the internal implementation details
in order to not break the existing documentation. Either way is not good
and that's why I am saying no to your proposed documentation change.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [TASK] Allow customizeable ditaa executable in ob-ditaa.el

2023-11-11 Thread Ihor Radchenko
Leo Butler  writes:

> I am glad we agree. Now let me tell you my dilemma: a while ago, I
> suggested a patch to implement similar functionality for ob-maxima. The
> patch used customization variables, much like ob-plantuml does. Ihor's
> feedback was that this was not a good approach (too much room for
> accidental breakage, etc.). Eventually, the patch was amended to acheive
> the same goals using new header arguments.
>
> So, now, in my opinion, consistency would dictate that we re-visit the
> changes made to ob-plantuml, re-fashion them and do something similar
> with ob-ditaa. Except, users have likely become accustomed to using
> ob-plantuml as it is...
>
> Thoughts?

Let me clarify.

For ob-maxima, my main concern was that we _need_ certain header
arguments to parse the output of Maxima. So, those _required_ header
arguments should be hard-coded and not customizeable. Other header
arguments may be customizeable (via header args or defcustom; header
args is more flexible).

This is not the case for ob-plantuml - the default -headless argument
may be safely removed; it just makes loading java faster.


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Issue with org-persist and Tramp

2023-11-11 Thread Fabio Natali
On 2023-11-10, 11:26 +, Fabio Natali  wrote:
> On 2023-11-10, 11:13 +, Fabio Natali  wrote:
>> Brilliant. I think the second branch should read `(not (file-remote-p
>> file))', i.e. `file' instead of `associated'? It seems to work with that
>> micro amendment.
>
> Hm, I stand corrected, I retested it end-to-end and no, it doesn't seem
> to work. I'll post more details later. Cheers, Fabio.

Hi Ihor,

Sorry for the delay. My results below, after testing a couple of
different cases.

If the remote file had been saved before losing connection, then the
patch below will fix the problem. TRAMP will still hang for a while, as
it tries to reach the server but the buffer will be closed immediately
when using `tramp-cleanup-all-buffers' (or a variant thereof).

--- /tmp/test-0.el  2023-11-11 09:27:33.477117451 +
+++ /tmp/test-1.el  2023-11-11 09:27:14.217129703 +
@@ -5,7 +5,8 @@
  (unless (stringp associated)
(setq associated (cadr associated)))
  (let* ((rtn `(:file ,associated))
-(inode (and (fboundp 'file-attribute-inode-number)
+(inode (and (not (file-remote-p associated))
+   (fboundp 'file-attribute-inode-number)
 (file-attribute-inode-number
  (file-attributes associated)
(when inode (plist-put rtn :inode inode))
@@ -25,6 +26,7 @@
  (or (buffer-base-buffer associated)
  associated)))
  (setq inode (when (and file
+   (not (file-remote-p file))
 (fboundp 'file-attribute-inode-number))
(file-attribute-inode-number
 (file-attributes file

(Apologies, the patch is badly formatted and not meant for the
repository.) The gist is that I replaced an occurrence of `associated'
with `file' in your latest patch, Ihor. It seems to work, what do you
think?

However, if the remote file hadn't been saved, then TRAMP will still
hang indefinitely. Quitting will reveal the following backtrace:

Debugger entered--Lisp error: (quit "")
  signal(quit (""))
  tramp-error(nil quit "")
  tramp-signal-hook-function(quit (""))
  signal(quit (""))
  tramp-maybe-open-connection((tramp-file-name "ssh" nil nil "192.168.1.100" 
nil "~/.#test.org" nil))
  tramp-send-command((tramp-file-name "ssh" nil nil "192.168.1.100" nil 
"~/.#test.org" nil) "echo ~ 2>/dev/null; echo tramp_exit_status $?")
  tramp-send-command-and-check((tramp-file-name "ssh" nil nil "192.168.1.100" 
nil "~/.#test.org" nil) "echo ~")
  tramp-sh-handle-get-home-directory((tramp-file-name "ssh" nil nil 
"192.168.1.100" nil "~/.#test.org" nil) "")
  tramp-sh-file-name-handler(tramp-get-home-directory (tramp-file-name "ssh" 
nil nil "192.168.1.100" nil "~/.#test.org" nil) "")
  apply(tramp-sh-file-name-handler tramp-get-home-directory ((tramp-file-name 
"ssh" nil nil "192.168.1.100" nil "~/.#test.org" nil) ""))
  tramp-file-name-handler(tramp-get-home-directory (tramp-file-name "ssh" nil 
nil "192.168.1.100" nil "~/.#test.org" nil) "")
  tramp-get-home-directory((tramp-file-name "ssh" nil nil "192.168.1.100" nil 
"~/.#test.org" nil) "")
  tramp-sh-handle-expand-file-name("/ssh:192.168.1.100:~/.#test.org" nil)
  tramp-sh-file-name-handler(expand-file-name "/ssh:192.168.1.100:~/.#test.org" 
nil)
  apply(tramp-sh-file-name-handler expand-file-name 
("/ssh:192.168.1.100:~/.#test.org" nil))
  tramp-file-name-handler(expand-file-name "/ssh:192.168.1.100:~/.#test.org" 
nil)
  files--transform-file-name("/ssh:192.168.1.100:~/test.org" nil ".#" "")
  make-lock-file-name("/ssh:192.168.1.100:~/test.org")
  tramp-run-real-handler(make-lock-file-name ("/ssh:192.168.1.100:~/test.org"))
  tramp-handle-make-lock-file-name("/ssh:192.168.1.100:~/test.org")
  tramp-sh-file-name-handler(make-lock-file-name 
"/ssh:192.168.1.100:~/test.org")
  apply(tramp-sh-file-name-handler make-lock-file-name 
"/ssh:192.168.1.100:~/test.org")
  tramp-file-name-handler(make-lock-file-name "/ssh:192.168.1.100:~/test.org")
  tramp-compat-make-lock-file-name("/ssh:192.168.1.100:~/test.org")
  tramp-handle-unlock-file("/ssh:192.168.1.100:~/test.org")
  tramp-sh-file-name-handler(unlock-file "/ssh:192.168.1.100:~/test.org")
  apply(tramp-sh-file-name-handler unlock-file "/ssh:192.168.1.100:~/test.org")
  tramp-file-name-handler(unlock-file "/ssh:192.168.1.100:~/test.org")
  kill-buffer("test.org")
  funcall-interactively(kill-buffer "test.org")
  command-execute(kill-buffer)

This seems to be on the TRAMP side?

Cheers, Fabio.



Re: Slowdown with large headings in view

2023-11-11 Thread Ihor Radchenko
Sebastian Wålinder  writes:

> I have massive org-mode file with thousands of SRC blocks.
>
> As the file grew, I started to get very poor performance, but setting 
> `org-fold-core--ignore-modifications` to `t` solved it.
>
> However, I still get very poor performance when a lot of folded headings are 
> in view. It gets slower as headings with more text hidden inside its fold 
> come into view.
>
> I have tried running the profiler to find out what the issue is, but no 
> matter how laggy Emacs gets, the profiler records practically no CPU samples 
> or memory usage.
>
> When the massive org buffer is in view and showing large folded headlines, 
> any command run is very slow, even if the action is performed in another 
> buffer entirely. It returns to normal when no window is showing the headings, 
> as well as when I bring the folded headings out of view or unfold them.

This is expected. The problem is with Emacs redisplay engine that cannot
easily handle large number of text properties - on C level.

You can try to set `org-fold-core--optimise-for-huge-buffers' to
'(grab-invisible) locally in the problematic Org file - it should reduce
the number of text properties used at the cost of not preserving folded
drawers when folding the containing heading.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Org site is down

2023-11-11 Thread Ihor Radchenko
Bastien Guerry  writes:

> Let's see if Woof can track new patches and tasks, for example.
> I'll monitor this, you don't need to worry about it right now.

I do see patches and requests being added after the update, but not
bugs. The latest registered bug report is from Nov 1 - see
https://tracker.orgmode.org/bugs?sorting-by=date

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] tmp [9.7-pre (release_9.6.10-881-g595a32 @ /home/ps/.emacs.d/org-mode-git/lisp/)]

2023-11-11 Thread Ihor Radchenko
Paul Stansell  writes:

> When using Org Mode version 9.7-pre (release_9.6.10-881-g595a32) the
> following happens that doesn't happen when using Org Mode version 9.5.5
> (release_9.5.5 @ /usr/share/emacs/28.2/lisp/org/)]:
>
> When the cursor is at the end of a folded section, that is, immediately
> after the ellipses, and return is pressed the folded section is made
> visible (i.e., it is unfolded).

This is expected.

> This is particularly problematic when adding a new section after the last
> section in an org file.  If the last section is folded it seems impossible
> to get the cursor beyond the final ellipses so when adding a new section
> below this one (using return or Alt-return) the previous section is
> always opened.  For sections that aren't the last one can put the cursor at
> the start of the next section and press Alt-return to insert a new section
> above it without unfolding any sections.

You can customize `org-fold-catch-invisible-edits' to return to past behavior.
Alternatively, use C-, which makes sure that formatting is not
broken despite editing near folded region.

Not a bug.
Canceled.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: Replace org link with footnote

2023-11-11 Thread Matt


  On Sat, 11 Nov 2023 04:54:15 +0100  Max Nikulin  wrote --- 

 > https://list.orgmode.org/ugucve$12l4$1...@ciao.gmane.io

Thanks for the reference.  It's always good to relate associated information :)



Re: [PATCH] testing: Delete duplicate tests

2023-11-11 Thread Ilya Chernyshov
Ihor Radchenko  writes:

> I saw you using your function to detect the existing duplicate tests.
> However, it would also be nice to add it as a test of its own to detect
> duplicates in future. WDYT?

Sure, here it is. In the patch, I added a new file
(testing/lisp/test-deduplicator.el) with a test that checks for
duplicate forms (not just should, should-not, should-error macros) in
all test files.

Changes in other files serve as an example of how to use
`org-test-ignore-duplicate' to make sure that the test deduplicator
skips certain duplicate forms.

There's a lot of tests to change before merging. I'll handle them and
submit a new patch if you have no questions about the code.

>From 3b38450f7de8bd168d8795728454d9f4db720843 Mon Sep 17 00:00:00 2001
From: Ilya Chernyshov 
Date: Tue, 5 Sep 2023 22:40:59 +0700
Subject: [PATCH] testing: Add testing/lisp/test-deduplicator.el

* testing/lisp/test-deduplicator.el: Add test unit that checks for
duplicate forms in ert tests.

* testing/lisp/test-ob-lob.el (test-ob-lob/caching-call-line,
test-ob-lob/named-caching-call-line, test-ob/just-one-results-block):
Ignore duplicate forms via `org-test-ignore-duplicate'

* testing/lisp/test-ob.el (test-ob/just-one-results-block): Ignore
duplicate forms via `org-test-ignore-duplicate'

* testing/lisp/test-org.el (test-org/goto-sibling,
test-org/backward-element, test-org/up-element): Ignore duplicate
forms via `org-test-ignore-duplicate'
---
 testing/lisp/test-deduplicator.el | 224 ++
 testing/lisp/test-ob-lob.el   |  10 +-
 testing/lisp/test-ob.el   |   3 +-
 testing/lisp/test-org.el  |  81 ++-
 4 files changed, 275 insertions(+), 43 deletions(-)
 create mode 100644 testing/lisp/test-deduplicator.el

diff --git a/testing/lisp/test-deduplicator.el b/testing/lisp/test-deduplicator.el
new file mode 100644
index 0..28b5d66f0
--- /dev/null
+++ b/testing/lisp/test-deduplicator.el
@@ -0,0 +1,224 @@
+;;; test-deduplicator.el --- Tests for finding duplicates in Org tests  -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2023  Ilya Chernyshov
+;; Authors: Ilya Chernyshov 
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see .
+;;
+;;; Commentary:
+
+;; Unit tests that check for duplicate forms (including `should',
+;; `should-not', `should-error') in all Org test files.  Forms are
+;; considered duplicate if they are `equal-including-properties' and
+;; nested at the same level.  To ignore a form or a group of forms,
+;; wrap them in `org-test-ignore-duplicate'.
+
+;;; Code:
+
+(require 'org-test "../testing/org-test")
+
+(defvar test-deduplicator-files
+  (directory-files (expand-file-name "lisp" org-test-dir) t "\\.el$"))
+
+(defvar test-deduplicator-duplicate-forms nil
+  "A nested list of the form:
+
+  (((file test-name [(form-1 . numerical-order)
+ (form-2 . numerical-order) ...])
+(dup-form-1 . (numerical-order [numerical-order ...]))
+  [ (dup-form-2 . (numerical-order [numerical-order ...]))
+(dup-form-3 . (numerical-order [numerical-order ...]))
+ ...])
+   
+   ((file test-name [(form-1 . numerical-order)
+ (form-2 . numerical-order) ...])
+(dup-form-1 . (numerical-order [numerical-order ...]))
+  [ (dup-form-2 . (numerical-order [numerical-order ...]))
+(dup-form-3 . (numerical-order [numerical-order ...]))
+ ...])
+
+   ...
+  )
+
+Where
+
+  (file test-name [(form-1 . numerical-order)
+   (form-2 . numerical-order) ...])
+
+is a path to duplicates.  For example, the path for the
+duplicates in the following test:
+
+ test-ob-haskell-ghci.el
+
+  (ertdeftest ob-haskell/session-named-none-means-one-shot-sessions ()
+\"When no session, use a new session.
+  \"none\" is a special name that means `no session'.\"
+(let ((var-1 \"value\"))
+ (when var-1
+   (should-not (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil)))
+   (test-ob-haskell-ghci \":session none\" \"x=2\")
+   (should-not (equal 2 (test-ob-haskell-ghci \":session \"none\"\" \"x\" nil)))
+   (test-ob-haskell-ghci \":session none\" \"x=2\"
+
+would look like this:
+
+  (\"test-ob-haskell-ghci.el\"
+ob-haskell/session-named-none-means-one-shot-sessions
+(let . 4) (when . 2))
+
+And the