Re: [BUG] Let org-latex-compile fall back on org-latex-compiler as the default instead of "pdflatex" [9.6 (9.6-??-4f0f24447 @ /home/dan/.emacsen/doom-emacs/.local/straight/build-29.0.50/org/)]

2022-05-21 Thread Ihor Radchenko
daanturo  writes:

> On 5/22/22 10:42, Ihor Radchenko wrote:
>> Can you provide more details on the problem?
>> `org-latex-compile' relies on `org-latex--insert-compiler' that is
>> called by `org-latex-template'. So, your org-latex-compiler
>> customization should be obeyed.
>
> Sorry, I was a problem on my side, the file where I test has 
> `org-latex-compiler-file-string' set to nil as a local variable.

Note that `org-latex-compiler-file-string' must not be set to nil. It is
not considered a valid value and causes undefined behavior.

> But IMO, falling back to the customized `org-latex-compiler' instead of 
> "pdflatex" should be intuitive.

Not necessarily. If org-latex-compiler is not a member of
org-latex-compilers, we need some sane fallback. Moreover, apart from
org-latex-compiler variable, the compiler can be set locally in buffer
or locally in the subtree. Either way, it is not necessarily clear which
fallback is reasonable. I'd go as far as throwing an error instead of
using "pdflatex", but alas, we already have the existing behavior and
changing it without strong justification can break things for other
users.

Docstring of org-latex-compiler:

>>> Must be an element in org-latex-compilers or the empty quote.
>>> Can also be set in buffers via #+LATEX_COMPILER.  See also
>>> org-latex-compiler-file-string.

Best,
Ihor

P.S. You dropped org mailing list from CC. Please, use "reply all" when
replying to the Org mailing list messages in future.



[BUG] org-open-file immediately termininates when calling xdg-open that calls emacsclient [9.5.3 (release_9.5.3-508-ge268e4 @ /home/yantar92/.emacs.d/straight/build/org/)]

2022-05-21 Thread Ihor Radchenko
Hi,

I have a problem with the following commits:

869b7a21b org-open-file: Avoid make-process for Emacs 24 compatibility
5db61eb0f org.el: Avoid xdg-open silent failure

They both set process-connection-type to nil/'pipe. Somehow, this change
breaks org-open-file for me when org-open-file calls xdg-open and xdg is
confugured to open the file with emacsclient. I only see a flicker and
the file does not open. Sometimes, Emacs even crashes.

If I change the process type back to default tty value, things work
again as expected.

While I understand that the original commits intended to solve a similar
problem, they clearly caused the same problem with other apps.

Best,
Ihor

Emacs  : GNU Emacs 28.1.50 (build 1, x86_64-pc-linux-gnu, cairo version 1.16.0)
 of 2022-05-14
Package: Org mode version 9.5.3 (release_9.5.3-508-ge268e4 @ 
/home/yantar92/.emacs.d/straight/build/org/)
-- 



[PATCH] Re: Bug in 9.5.3 org--file-default-apps

2022-05-21 Thread Ihor Radchenko
Max Nikulin  writes:

> On 21/05/2022 08:44, Ihor Radchenko wrote:
>> Max Nikulin writes:
>> 
>>> It is the same with and without -Q and no, I have not customized
>>> `mailcap-user-mime-data', its value is nil, easy customization interface
>>> tells that it is the standard value. There is a chance that debian has
>>> some patch, but most of debian specific is disabled when -Q option is used.
>> 
>> Interesting. In any case, it confirms that mailcap behaviour depends on
>> both Emacs settings and also system settings.
>
> You should be even more surprised, if I say that [[file:~/tstorg]] link 
> is opened in emacs buffer in shell-script mode (emacs-27.1, org main 
> HEAD) despite
>
> (mailcap-mime-info nil)
> nil

>
> The source of the problem is that Emacs-27 was released with the 
> following bug:
>
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=40247
> mailcap-mime-data erased when parsing mime parts
>
> So `mailcap-parse-mailcaps' called from `mailcap-mime-info' erases 
> predefined associations in Emacs-27.

If I understand correctly, this extra complication does not affect most
of the systems. I am not sure if we need to work around it.

Also, I am attaching a patch to address the original issue. We can just
use file command when available. WDYT?

Best,
Ihor

>From f69824559d62cb6963ff30f11ceb46303bf1b3d4 Mon Sep 17 00:00:00 2001
Message-Id: 
From: Ihor Radchenko 
Date: Sun, 22 May 2022 12:04:35 +0800
Subject: [PATCH] org-open-file: Use file command to determine mime type, when
 available

* lisp/org.el (org-open-file): Prefer file command to determine file
type instead of relying on `mailcap-extension-to-mime'.  Only fallback
to the latter when file command is not available on the system.

Fixes https://list.orgmode.org/874k1n2hpv.fsf@localhost/T/#mcc10df4ea7937360671e6dea8061153dee518807
---
 lisp/org.el | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index d7da8efc4..3102fe611 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7975,7 +7975,12 @@ (defun org-open-file (path  in-emacs line search)
 (when (eq cmd 'mailcap)
   (require 'mailcap)
   (mailcap-parse-mailcaps)
-  (let* ((mime-type (mailcap-extension-to-mime (or ext "")))
+  (let* ((mime-type (if (executable-find "file")
+(shell-command-to-string
+ (format "%s --brief --mime-type %s"
+ (executable-find "file")
+ file))
+  (mailcap-extension-to-mime (or ext ""
 	 (command (mailcap-mime-info mime-type)))
 	(if (stringp command)
 	(setq cmd command)
-- 
2.35.1



[PATCH] Avoid ignoring LaTeX export output errors when org-latex-pdf-process is a list

2022-05-21 Thread Ihor Radchenko
Hi,

The attached patch is fixing a rather annoying problem when
org-latex-pdf-process is set to a list. Currently, only output of the
last command in the list is preserved in *Org PDF LaTeX output* buffer,
which sometimes prevents ox-latex from detecting compilation warnings.

ox-latex relies on *Org PDF LaTeX output* to contain the output of latex
compiler. However, unless the last command in the org-latex-pdf-process
is something like pdflatex, the compiler errors are erased by
`shell-command' called by `org-compile-file'.

Best,
Ihor

>From d4f15ed260f47195b01cb60061b57823428d2eef Mon Sep 17 00:00:00 2001
Message-Id: 
From: Ihor Radchenko 
Date: Sun, 22 May 2022 11:44:56 +0800
Subject: [PATCH] Avoid ignoring LaTeX export output errors

* lisp/org-macs.el (org-compile-file): When PROCESS is a list, keep
output of all the listed commands, not just the last one.
* lisp/ox-latex.el (org-latex-pdf-process): Clarify that the process
output is parsed to detect compilation errors/warnings.
---
 lisp/org-macs.el | 9 +++--
 lisp/ox-latex.el | 3 +++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 10eed2686..2a7131ded 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -323,8 +323,13 @@ (defun org-compile-file (source process ext  err-msg log-buf spec)
 			   (?F . ,(shell-quote-argument full-name))
 			   (?o . ,(shell-quote-argument out-dir))
 			   (?O . ,(shell-quote-argument output))
-	   (dolist (command process)
-	 (shell-command (format-spec command spec) log-buf))
+   ;; Combine output of all commands in PROCESS.
+   (with-current-buffer log-buf
+ (let (buffer-read-only)
+   (erase-buffer)))
+   (let ((shell-command-dont-erase-buffer t))
+	 (dolist (command process)
+	   (shell-command (format-spec command spec) log-buf)))
 	   (when log-buf (with-current-buffer log-buf (compilation-mode)
 	(_ (error "No valid command to process %S%s" source err-msg
 ;; Check for process failure.  Output file is expected to be
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 5a2de8afb..ed16ec46f 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1426,6 +1426,9 @@ (defcustom org-latex-pdf-process
   "%latex -interaction nonstopmode -output-directory %o %f"))
   "Commands to process a LaTeX file to a PDF file.
 
+The command output will be parsed to extract compilation errors and
+warnings according to `org-latex-known-warnings'.
+
 This is a list of strings, each of them will be given to the
 shell as a command.  %f in the command will be replaced by the
 relative file name, %F by the absolute file name, %b by the file
-- 
2.35.1



Re: [BUG] Let org-latex-compile fall back on org-latex-compiler as the default instead of "pdflatex" [9.6 (9.6-??-4f0f24447 @ /home/dan/.emacsen/doom-emacs/.local/straight/build-29.0.50/org/)]

2022-05-21 Thread Ihor Radchenko
daanturo  writes:

> Having set `org-latex-compiler` to `lualatex`, when exporting with
> `org-latex-export-to-pdf`, I expected that `lualatex` is the compiler to
> be used but `org-latex-compile` falled back on `pdflatex` instead.

Can you provide more details on the problem?
`org-latex-compile' relies on `org-latex--insert-compiler' that is
called by `org-latex-template'. So, your org-latex-compiler
customization should be obeyed.

Best,
Ihor



Re: Bug in 9.5.3 org--file-default-apps

2022-05-21 Thread Max Nikulin

On 21/05/2022 08:44, Ihor Radchenko wrote:

Max Nikulin writes:


It is the same with and without -Q and no, I have not customized
`mailcap-user-mime-data', its value is nil, easy customization interface
tells that it is the standard value. There is a chance that debian has
some patch, but most of debian specific is disabled when -Q option is used.


Interesting. In any case, it confirms that mailcap behaviour depends on
both Emacs settings and also system settings.


You should be even more surprised, if I say that [[file:~/tstorg]] link 
is opened in emacs buffer in shell-script mode (emacs-27.1, org main 
HEAD) despite


   (mailcap-mime-info nil)
   nil

actually it is a minimal LXC container with no mime-support package 
installed, so /etc/mailcap file is absent.


Notice `mailcap-mime-data' has the following entries for a long time
("text"
 ("plain"
  (viewer  . view-mode)
  (type. "text/plain"))
 ("plain"
  (viewer  . fundamental-mode)
  (type. "text/plain"))

The source of the problem is that Emacs-27 was released with the 
following bug:


https://debbugs.gnu.org/cgi/bugreport.cgi?bug=40247
mailcap-mime-data erased when parsing mime parts

So `mailcap-parse-mailcaps' called from `mailcap-mime-info' erases 
predefined associations in Emacs-27.





[BUG] Let org-latex-compile fall back on org-latex-compiler as the default instead of "pdflatex" [9.6 (9.6-??-4f0f24447 @ /home/dan/.emacsen/doom-emacs/.local/straight/build-29.0.50/org/)]

2022-05-21 Thread daanturo
Remember to cover the basics, that is, what you expected to happen and
what in fact did happen. You don't know how to make a good report? See

https://orgmode.org/manual/Feedback.html#Feedback

Your bug report will be posted to the Org mailing list.


Having set `org-latex-compiler` to `lualatex`, when exporting with
`org-latex-export-to-pdf`, I expected that `lualatex` is the compiler to
be used but `org-latex-compile` falled back on `pdflatex` instead.


Emacs  : GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, 
cairo version 1.17.6)
 of 2022-05-20
Package: Org mode version 9.6 (9.6-??-4f0f24447 @ 
/home/dan/.emacsen/doom-emacs/.local/straight/build-29.0.50/org/)
 
current state:
==
(setq
 org-link-elisp-confirm-function nil
 org-directory "~/Documents/org"
 org-after-refile-insert-hook '(save-buffer)
 org-indirect-buffer-display 'current-window
 org-crypt-key nil
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-load-hook '(+org-init-org-directory-h
 +org-init-appearance-h +org-init-agenda-h
 +org-init-attachments-h +org-init-babel-h
 +org-init-babel-lazy-loader-h
 +org-init-capture-defaults-h
 +org-init-capture-frame-h
 +org-init-custom-links-h +org-init-export-h
 +org-init-habit-h +org-init-hacks-h
 +org-init-keybinds-h +org-init-popup-rules-h
 +org-init-protocol-h
 +org-init-protocol-lazy-loader-h
 +org-init-smartparens-h)
 org-startup-folded nil
 org-babel-after-execute-hook '(+org-redisplay-inline-images-in-babel-result-h)
 org-link-abbrev-alist '(("doom-repo" .
  "https://github.com/hlissner/doom-emacs/%s;)
 ("wolfram" .
  "https://wolframalpha.com/input/?i=%s;)
 ("wikipedia" .
  "https://en.wikipedia.org/wiki/%s;)
 ("duckduckgo" .
  "https://duckduckgo.com/?q=%s;)
 ("gmap" .
  "https://maps.google.com/maps?q=%s;)
 ("gimages" .
  "https://google.com/images?q=%s;)
 ("google" .
  "https://google.com/search?q=;)
 ("youtube" .
  "https://youtube.com/watch?v=%s;)
 ("github" . "https://github.com/%s;))
 org-agenda-files '("~/Documents/org")
 org-capture-templates '(("t" "Personal todo" entry
  (file+headline
   +org-capture-todo-file "Inbox")
  "* [ ] %?\n%i\n%a" :prepend t)
 ("n" "Personal notes" entry
  (file+headline
   +org-capture-notes-file "Inbox")
  "* %u %?\n%i\n%a" :prepend t)
 ("j" "Journal" entry
  (file+olp+datetree
   +org-capture-journal-file)
  "* %U %?\n%i\n%a" :prepend t)
 ("p" "Templates for projects")
 ("pt" "Project-local todo" entry
  (file+headline
   +org-capture-project-todo-file
   "Inbox")
  "* TODO %?\n%i\n%a" :prepend t)
 ("pn" "Project-local notes" entry
  (file+headline
   +org-capture-project-notes-file
   "Inbox")
  "* %U %?\n%i\n%a" :prepend t)
 ("pc" "Project-local changelog" entry
  (file+headline
   +org-capture-project-changelog-file
   "Unreleased")
  "* %U %?\n%i\n%a" :prepend t)
 ("o"
  "Centralized templates for projects")
 ("ot" "Project todo" entry
  #'+org-capture-central-project-todo-file "* TODO %?\n 
%i\n %a" :heading "Tasks" :prepend nil)
 ("on" "Project notes" entry
  #'+org-capture-central-project-notes-file "* %U %?\n 
%i\n %a" :heading "Notes" :prepend t)
 ("oc" "Project changelog" entry
  #'+org-capture-central-project-changelog-file "* %U 
%?\n %i\n %a" :heading "Changelog" :prepend t)
 )
 org-persist-after-read-hook '(org-element--cache-persist-after-read)
 org-re-reveal-root 
"/home/dan/.emacsen/doom-emacs/.local/straight/build-29.0.50/revealjs/"
 org-refile-targets '((nil :maxlevel . 3)

Re: [BUG] HTML export of buffer with fringe indicators

2022-05-21 Thread Ihor Radchenko
Daniel Fleischer  writes:

> Ihor Radchenko [2022-05-20 Fri 16:36]  wrote:
>
>> I am unable to reproduce your problem on my side using the following
>> steps.
>
> Ok, thanks anyway. BTW, even the steps you took are useful for me for future 
> debugging. 

It is exactly the reason I listed the steps. So that you can also try on
your side.

If you cannot reproduce using my steps, there is a chance that the
problem is also caused by some other part of your config. In which case,
you can use https://github.com/Malabarba/elisp-bug-hunter to hunt down
the cause. Also, see
https://open.tube/videos/watch/4d819114-43bf-42df-af94-f94fc53dd0d9

Best,
Ihor



Re: [BUG] HTML export of buffer with fringe indicators

2022-05-21 Thread Daniel Fleischer
Ihor Radchenko [2022-05-20 Fri 16:36]  wrote:

> I am unable to reproduce your problem on my side using the following
> steps.

Ok, thanks anyway. BTW, even the steps you took are useful for me for future 
debugging. 

Best,

Daniel Fleischer


Re: Fwd: [BUG] when open a large org file, emacs get stuck and show a warning "org-element--cache: Unregistered buffer modifications detected"

2022-05-21 Thread Ihor Radchenko
imymorror wang  writes:

>>Now, it is confusing. I am unable to reproduce the warning on my side
>>even with org-fragtog and valign installed.
>
> valign-mode causes the problem. Try these steps to reproduce the problem :
> add-hook for valign and open a large org file, then try moving the mouse a
> few times,quickly TAB and SHIFT-TAB a few times.

Thanks! I have opened an issue in valign repo:
https://github.com/casouri/valign/issues/30

This problem needs to be fixed on valign side.

Best,
Ihor



Re: Fwd: [BUG] when open a large org file, emacs get stuck and show a warning "org-element--cache: Unregistered buffer modifications detected"

2022-05-21 Thread imymorror wang
>Now, it is confusing. I am unable to reproduce the warning on my side
>even with org-fragtog and valign installed.

valign-mode causes the problem. Try these steps to reproduce the problem :
add-hook for valign and open a large org file, then try moving the mouse a
few times,quickly TAB and SHIFT-TAB a few times.

Ihor Radchenko  于2022年5月21日周六 12:37写道:

> imymorror wang  writes:
>
> >> Can you share the values of change-major-mode-hook and org-mode-hook?
> > I uploaded all *emacs **current state* in recent e-mail .
>
> Sorry, I missed that. Unfortunately I do not see anything suspicious
> there.
>
> Now, it is confusing. I am unable to reproduce the warning on my side
> even with org-fragtog and valign installed.
>
> Can you try to reproduce the problem starting from clean Emacs state
> (emacs -Q)? See https://orgmode.org/manual/Feedback.html
>
> >> Also, do you deliberately drop the CC to emacs-orgmode@gnu.org and
> prefer
> > the conversation to be not public?
> > sorry. I'm not good at email communication. This is my first attempt to
> > submit a bug report to Emacs. Maybe I could add CC to
> emacs-orgmode@gnu.org on
> > the recent email that shows all my emacs current state info.
>
> Just use "Reply All" in future.
>
> Best,
> Ihor
>


Re: Fwd: [BUG] when open a large org file, emacs get stuck and show a warning "org-element--cache: Unregistered buffer modifications detected"

2022-05-21 Thread imymorror wang
>Can you try to reproduce the problem starting from clean Emacs state
>(emacs -Q)? See https://orgmode.org/manual/Feedback.html
thank you for reminding me to use this method.


I found out why. package *valign-mode*(https://github.com/casouri/valign)
causes the problem:

(add-hook 'org-mode-hook #'valign-mode)

If I don't add-hook for valign-mode, everything works fine.

Ihor Radchenko  于2022年5月21日周六 12:37写道:

> imymorror wang  writes:
>
> >> Can you share the values of change-major-mode-hook and org-mode-hook?
> > I uploaded all *emacs **current state* in recent e-mail .
>
> Sorry, I missed that. Unfortunately I do not see anything suspicious
> there.
>
> Now, it is confusing. I am unable to reproduce the warning on my side
> even with org-fragtog and valign installed.
>
> Can you try to reproduce the problem starting from clean Emacs state
> (emacs -Q)? See https://orgmode.org/manual/Feedback.html
>
> >> Also, do you deliberately drop the CC to emacs-orgmode@gnu.org and
> prefer
> > the conversation to be not public?
> > sorry. I'm not good at email communication. This is my first attempt to
> > submit a bug report to Emacs. Maybe I could add CC to
> emacs-orgmode@gnu.org on
> > the recent email that shows all my emacs current state info.
>
> Just use "Reply All" in future.
>
> Best,
> Ihor
>


Re: [BUG] when open a large org file, emacs get stuck and show a warning "org-element--cache: Unregistered buffer modifications detected"

2022-05-21 Thread imymorror wang
> Can you share the values of change-major-mode-hook and org-mode-hook?
I search change-major-mode-hook and org-mode-hook by C-h v(describe-variable).
the result is

```
change-major-mode-hook is a variable defined in ‘C source code’.

Its value is (font-lock-change-mode t)
Local in buffer *Help*; global value is
(global-company-mode-cmhh yas-global-mode-cmhh smartparens-global-mode-cmhh
ctrlf-mode-cmhh ace-pinyin-global-mode-cmhh meow-global-mode-cmhh
global-eldoc-mode-cmhh global-font-lock-mode-cmhh)

Normal hook run before changing the major mode of a buffer.
The function ‘kill-all-local-variables’ runs this before doing anything
else.

  This variable may be risky if used as a file-local variable.
  Probably introduced at or before Emacs version 19.23.
```

```
org-mode-hook is a variable defined in ‘org.el’.

Its value is shown below.

Mode hook for Org mode, run after the mode was turned on.

  This variable may be risky if used as a file-local variable.
  You can customize this variable.

Value:
(#f(compiled-function
()
#)
   #f(compiled-function
  ()
  #)
   rasmus/org-prettify-symbols org-fragtog-mode org-indent-mode valign-mode
#f(compiled-function
  ()
  #)
   #f(compiled-function
  ()
  #)
   org-babel-result-hide-spec org-babel-hide-all-hashes)
Original value was nil
```

imymorror wang  于2022年5月21日周六 11:58写道:

> > Can you share the values of change-major-mode-hook and org-mode-hook?
> I uploaded all *emacs **current state* in recent e-mail .
>
> > Also, do you deliberately drop the CC to emacs-orgmode@gnu.org and
> prefer the conversation to be not public?
> sorry. I'm not good at email communication. This is my first attempt to
> submit a bug report to Emacs. Maybe I could add CC to
> emacs-orgmode@gnu.org on the recent email that shows all my emacs current
> state info.
>
> -- Forwarded message -
> 发件人: Ihor Radchenko 
> Date: 2022年5月21日周六 09:33
> Subject: Re: [BUG] when open a large org file, emacs get stuck and show a
> warning "org-element--cache: Unregistered buffer modifications detected"
> To: imymorror wang 
>
>
>
> imymorror wang  writes:
>
> > sorry . the whole warning text is (twice):
> > #+begin_quote
> > Warning (org-element-cache): org-element--cache: Unregistered buffer
> > modifications detected. Resetting.
> > If this warning appears regularly, please report the warning text to Org
> > mode mailing list (M-x org-submit-bug-report).
> > The buffer is: 20220404203228-2022_04_04_20_29_emacs_outline_emacs.org
> >  Current command: (next-line 14194 14229)
> >  Chars modified: 14194
> >  Buffer modified: 14229
> >  Backtrace:
> > nil Disable showing Disable logging
>
> Thanks!
> It appears that something is editing the buffer either before or after
> loading Org mode.
>
> Can you share the values of change-major-mode-hook and org-mode-hook?
>
> Also, do you deliberately drop the CC to emacs-orgmode@gnu.org and
> prefer the conversation to be not public?
>
> Best,
> Ihor
>


Re: Change of behavior of org-meta-return in 9.6/DoomEmacs?

2022-05-21 Thread Guillaume MULLER

Hi again,

Thanks for your response.


If you do C-h f org-meta-return, do you see something like "This
function has .. advice: .." towards the end of that *Help* buffer?


After investigation, the bug is in org-insert-heading in org 9.6 (Latest Doom - 
upgraded today - uses exactly version: (9.6-??-971eb68)

The documentation says:
"If point is in the middle of a line, split it and create a new
headline with the text in the current line after point (see
org-M-RET-may-split-line on how to modify this behavior).  As
a special case, on a headline, splitting can only happen on the
title itself.  E.g., this excludes breaking stars or tags.

Whatever the value(s) I put in org-M-RET-may-split-line , org-insert-heading 
*always* creates a new line with a empty heading/item and leaves anything that 
was on the initial heading/item in-place.

If someone can confirm this finding, I would be happy to create the 
corresponding bug report.

Have a nice day

--
Guillaume MULLER - PhD
DataScientist
Saint-Étienne
org-insert-heading is an interactive and byte-compiled function
defined in org.el.

Signature
(org-insert-heading  ARG INVISIBLE-OK TOP)

Documentation
Insert a new heading or an item with the same depth at point.

If point is at the beginning of a heading, insert a new heading
or a new headline above the current one.  When at the beginning
of a regular line of text, turn it into a heading.

If point is in the middle of a line, split it and create a new
headline with the text in the current line after point (see
org-M-RET-may-split-line on how to modify this behavior).  As
a special case, on a headline, splitting can only happen on the
title itself.  E.g., this excludes breaking stars or tags.

With a C-u prefix, set org-insert-heading-respect-content to
a non-nil value for the duration of the command.  This forces the
insertion of a heading after the current subtree, independently
on the location of point.

With a C-u C-u prefix, insert the heading at the end of the tree
above the current heading.  For example, if point is within a
2nd-level heading, then it will insert a 2nd-level heading at
the end of the 1st-level parent subtree.

When INVISIBLE-OK is set, stop at invisible headlines when going
back.  This is important for non-interactive uses of the
command.

When optional argument TOP is non-nil, insert a level 1 heading,
unconditionally.

Key Bindings
This command is not in any keymaps.

References
References in org.el:
(defun org-insert-heading-after-current ...)   1 reference
(defun org-insert-heading-respect-content ...) 1 reference
(defun org-insert-todo-heading ...)1 reference
(defun org-insert-subheading ...)  1 reference
(defun org-meta-return ...)2 references

Find all references Functions used by org-insert-heading

Debugging
Enable edebug Enable tracing
Disassemble Forget

Source Code
;; Defined in ~/.emacs.doom.d/.local/straight/repos/org/lisp/org.el
(defun org-insert-heading ( arg invisible-ok top)
  "Insert a new heading or an item with the same depth at point.

If point is at the beginning of a heading, insert a new heading
or a new headline above the current one.  When at the beginning
of a regular line of text, turn it into a heading.

If point is in the middle of a line, split it and create a new
headline with the text in the current line after point (see
`org-M-RET-may-split-line' on how to modify this behavior).  As
a special case, on a headline, splitting can only happen on the
title itself.  E.g., this excludes breaking stars or tags.

With a `\\[universal-argument]' prefix, set \
`org-insert-heading-respect-content' to
a non-nil value for the duration of the command.  This forces the
insertion of a heading after the current subtree, independently
on the location of point.

With a `\\[universal-argument] \\[universal-argument]' prefix, \
insert the heading at the end of the tree
above the current heading.  For example, if point is within a
2nd-level heading, then it will insert a 2nd-level heading at
the end of the 1st-level parent subtree.

When INVISIBLE-OK is set, stop at invisible headlines when going
back.  This is important for non-interactive uses of the
command.

When optional argument TOP is non-nil, insert a level 1 heading,
unconditionally."
  (interactive "P")
  (let* ((blank? (org--blank-before-heading-p (equal arg '(16
 (level (org-current-level))
 (stars (make-string (if (and level (not top)) level 1) ?*)))
(cond
 ((or org-insert-heading-respect-content
  (member arg '((4) (16)))
  (and (not invisible-ok)
   (invisible-p (max (1- (point)) (point-min)
  ;; Position point at the location of insertion.  Make sure we
  ;; end up on a visible headline if INVISIBLE-OK is nil.
  (org-with-limited-levels
   (if (not level) (outline-next-heading) ;before first headline
 (org-back-to-heading invisible-ok)
 (when (equal arg '(16)) 

Re: [BUG] when open a large org file, emacs get stuck and show a warning "org-element--cache: Unregistered buffer modifications detected"

2022-05-21 Thread imymorror wang
sorry. I sent a false message yesterday。I try again today. even upgrade to Org
mode version 9.5.3 (9.5.3-g277897), The problem still exists. But I find
out something new。you can see my *conclusion*. And I send all my emacs org
state.

 - desktop environment
   - GNU Emacs 29.0.50 (build 2, x86_64-apple-darwin20.4.0, NS
appkit-2022.44 Version 11.3.1 (Build 20E241)) of 2022-01-08
   - Org mode version 9.5.3 (9.5.3-g277897)
 - bug description
   - influence factor
 - a large org file : 11053 lines。1092 headlines。
 - (setq org-startup-folded t)
 - org-indent-mode : (add-hook 'org-mode-hook 'org-indent-mode)
   - My Observation
 - if setting org-startup-folded t , enable org-indent-mode, open the
large org file, emacs get stuck, the mouse can't move。
 - if keeping org-startup-folded defaul value(i.e  "showeverything") ,
enable org-indent-mode , open the large org file, get a warning, but not
get stuck:
   #+begin_quote
   Warning (org-element-cache): org-element--cache: Unregistered buffer
modifications detected. Resetting.
   If this warning appears regularly, please report it to Org mode
mailing list (M-x org-submit-bug-report).
   #+end_quote
 - if keeping org-startup-folded defaul value and disable
org-indent-mode , open the large org file, everything works fine.
 - if setting org-startup-folded t, disable org-indent-mode, everything
works fine.
 - conclusion
   - enalbe org-indent-mode cause the warning : "Warning
(org-element-cache): org-element--cache: Unregistered buffer modifications
detected."
   - setting org-startup-folded t, enable org-indent-mode. Having both
causes emacs get stuck.
   - In addition,it's not accurate to say that emacs get stuck. To be
precise, emacs get stuck, the mouse can't move for a few seconds and then
it works find.





---



Emacs  : GNU Emacs 29.0.50 (build 2, x86_64-apple-darwin20.4.0, NS
appkit-2022.44 Version 11.3.1 (Build 20E241))
 of 2022-01-08
Package: Org mode version 9.5.3 (9.5.3-g277897 @
/Users/fuhongxue/env/emacs/vanilla/straight/straight/build/org/)

current state:
==
(setq
 org-roam-db-location
"~/central-management-system/zotero/roam-db/2022-03-13-daily-based.db"
 org-link-elisp-confirm-function 'yes-or-no-p
 org-hide-emphasis-markers t
 org-bibtex-headline-format-function #[257 "\300 \236A\207" [:title] 3
"\n\n(fn ENTRY)"]
 org-download-file-format-function 'org-download-file-format-default
 org-roam-dailies-capture-templates '(("d" "default" entry "* %<%Y-%m-%d
%H:%M> %?" :if-new
  (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n#+filetags:
:daily:\n"))
 )
 org-startup-folded t
 org-roam-node-display-template "${tags:35} ${title:80}"
 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-tag-alist '(("review" . 114) ("summary" . 115) ("case" . 99) ("book" .
98) ("economics" . 101) ("refile" . 114) ("twitter" . 116) ("youtube" . 121)
("emacs" . 101) ("weibo" . 119) ("how" . 104))
 org-roam-find-file-hook '(org-roam-buffer--setup-redisplay-h
org-roam--register-completion-functions-h
org-roam--replace-roam-links-on-save-h
  org-roam-db-autosync--setup-update-on-save-h)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-footnote-auto-adjust t
 org-odt-format-inlinetask-function
'org-odt-format-inlinetask-default-function
 org-ascii-format-drawer-function #[771 " \207" [] 4 "\n\n(fn NAME CONTENTS
WIDTH)"]
 org-cycle-hook '(org-cycle-hide-archived-subtrees
org-cycle-show-empty-lines
org-cycle-optimize-window-after-visibility-change)
 org-persist-before-read-hook '(org-element--cache-persist-before-read)
 org-font-lock-set-keywords-hook '(doom-themes-enable-org-fontification)
 org-image-actual-width nil
 org-mode-hook '(rasmus/org-prettify-symbols org-fragtog-mode
org-indent-mode valign-mode
#[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-roam-ref-annotation-function 'org-roam-ref-read--annotation
 org-roam-directory
"~/central-management-system/zotero/notes/2022-03-13-daily-based"
 org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"]
 org-download-timestamp "%Y%m%d-%H%M%S_"
 org-roam-db-node-include-function #[0 "\300\207" [t] 1]
 org-download-abbreviate-filename-function 'file-relative-name
 org-latex-format-headline-function
'org-latex-format-headline-default-function
 org-confirm-shell-link-function 'yes-or-no-p
 org-download-annotate-function '(closure (t) (_link) "")
 

Fwd: [BUG] when open a large org file, emacs get stuck and show a warning "org-element--cache: Unregistered buffer modifications detected"

2022-05-21 Thread imymorror wang
> Can you share the values of change-major-mode-hook and org-mode-hook?
I uploaded all *emacs **current state* in recent e-mail .

> Also, do you deliberately drop the CC to emacs-orgmode@gnu.org and prefer
the conversation to be not public?
sorry. I'm not good at email communication. This is my first attempt to
submit a bug report to Emacs. Maybe I could add CC to  emacs-orgmode@gnu.org on
the recent email that shows all my emacs current state info.

-- Forwarded message -
发件人: Ihor Radchenko 
Date: 2022年5月21日周六 09:33
Subject: Re: [BUG] when open a large org file, emacs get stuck and show a
warning "org-element--cache: Unregistered buffer modifications detected"
To: imymorror wang 



imymorror wang  writes:

> sorry . the whole warning text is (twice):
> #+begin_quote
> Warning (org-element-cache): org-element--cache: Unregistered buffer
> modifications detected. Resetting.
> If this warning appears regularly, please report the warning text to Org
> mode mailing list (M-x org-submit-bug-report).
> The buffer is: 20220404203228-2022_04_04_20_29_emacs_outline_emacs.org
>  Current command: (next-line 14194 14229)
>  Chars modified: 14194
>  Buffer modified: 14229
>  Backtrace:
> nil Disable showing Disable logging

Thanks!
It appears that something is editing the buffer either before or after
loading Org mode.

Can you share the values of change-major-mode-hook and org-mode-hook?

Also, do you deliberately drop the CC to emacs-orgmode@gnu.org and
prefer the conversation to be not public?

Best,
Ihor