[BUG] org-element--cache Cached element is incorrect (ox-hugo) [9.6.10 (release_9.6.10 @ /home/gk/.emacs.d/lib/org/lisp/)]

2023-10-23 Thread George Kettleborough




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.


I've been having a problem where some of my exports get truncated
randomly at the end. I haven't been able to figure out the exact
problem, but by bisecting org-mode I found the problem appears in
072ddbc9 which sets `org-element--cache-self-verify' to t. By setting
this back to nil manually the truncation goes away, but the warning then
appears.

Interestingly I can only reproduce this when running emacs in batch
mode, not in regular mode.

I know ox-hugo and caching has come up before, but I don't think this
was the same problem as before.


Warning (org-element-cache): org-element--cache: (nil) Cached element is 
incorrect in *Ox-hugo Pre-processed programming.org *. (Cache tic up to 
date: "yes") Resetting.
If this warning appears regularly, please report the warning text to Org 
mode mailing list (M-x org-submit-bug-report).
The element is: "(headline (:raw-value \"Working on Multiple Web 
Projects with Docker Compose and Traefik\" :begin 85 :end 10406 
:pre-blank 0 :contents-begin 201 :contents-end 10405 :robust-begin 344 
:robust-end 10403 :level 1 :priority nil :tags (\"networking\" \"web\" 
\"development\" \"traefik\" \"docker\") :todo-keyword \"DONE\" 
:todo-type done :post-blank 1 :footnote-section-p nil :archivedp nil 
:commentedp nil :post-affiliated 85 :closed (timestamp (:type inactive 
:raw-value \"[2023-10-02 Mon 09:00]\" :year-start 2023 :month-start 10 
:day-start 2 :hour-start 9 :minute-start 0 :year-end 2023 :month-end 10 
:day-end 2 :hour-end 9 :minute-end 0 :begin 209 :end 231 :post-blank 0)) 
:EXPORT_FILE_NAME \"multiple-web-projects-traefik\" :EXPORT_HUGO_LASTMOD 
\"<2023-10-19 Thu 21:24>\" :title \"Working on Multiple Web Projects 
with Docker Compose and Traefik\" :mode nil :granularity element :cached 
t ...))"
The real element is: "(headline (:raw-value \"Working on Multiple Web 
Projects with Docker Compose and Traefik\" :begin 85 :end 10620 
:pre-blank 0 :contents-begin 201 :contents-end 10619 :robust-begin 344 
:robust-end 10617 :level 1 :priority nil :tags (\"networking\" \"web\" 
\"development\" \"traefik\" \"docker\") :todo-keyword \"DONE\" 
:todo-type done :post-blank 1 :footnote-section-p nil :archivedp nil 
:commentedp nil :post-affiliated 85 :closed (timestamp (:type inactive 
:raw-value \"[2023-10-02 Mon 09:00]\" :year-start 2023 :month-start 10 
:day-start 2 :hour-start 9 :minute-start 0 :year-end 2023 :month-end 10 
:day-end 2 :hour-end 9 :minute-end 0 :begin 209 :end 231 :post-blank 0)) 
:EXPORT_FILE_NAME \"multiple-web-projects-traefik\" :EXPORT_HUGO_LASTMOD 
\"<2023-10-19 Thu 21:24>\" :title \"Working on Multiple Web Projects 
with Docker Compose and Traefik\" :mode nil :granularity element :parent 
(org-data (:begin 1 :contents-begin 1 :contents-end 26390 :end 26390 
:robust-begin 3 :robust-end 26388 :post-blank 0 :post-affiliated 1 :path 
\"/home/gk/blog/content-org/programming.org\" :mode org-data :CATEGORY 
\"programming\""

Cache around :begin:
(keyword (:key "HUGO_CATEGORIES" :value "programming" :begin 53 :end 85 
:post-blank 1 :post-affiliated 53 :mode nil :granularity element :cached 
t :parent (section (:begin 1 :end 85 :contents-begin 1 :contents-end 84 
:robust-begin 1 :robust-end 82 :post-blank 1 :post-affiliated 1 :mode 
first-section :granularity element :cached t :parent (org-data (:begin 1 
:contents-begin 1 :contents-end 26390 :end 26390 :robust-begin 3 
:robust-end 26388 :post-blank 0 :post-affiliated 1 :path 
"/home/gk/blog/content-org/programming.org" :mode org-data :CATEGORY 
"programming" :cached t))
(keyword (:key "HUGO_CATEGORIES" :value "programming" :begin 53 :end 85 
:post-blank 1 :post-affiliated 53 :mode nil :granularity element :cached 
t :parent (section (:begin 1 :end 85 :contents-begin 1 :contents-end 84 
:robust-begin 1 :robust-end 82 :post-blank 1 :post-affiliated 1 :mode 
first-section :granularity element :cached t :parent (org-data (:begin 1 
:contents-begin 1 :contents-end 26390 :end 26390 :robust-begin 3 
:robust-end 26388 :post-blank 0 :post-affiliated 1 :path 
"/home/gk/blog/content-org/programming.org" :mode org-data :CATEGORY 
"programming" :cached t))

nil

Emacs : GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 
3.24.38, cairo version 1.17.8)

of 2023-10-02
Package: Org mode version 9.6.10 (release_9.6.10 @ 
/home/gk/.emacs.d/lib/org/lisp/)





Re: [O] Inline notes and alignment

2017-03-22 Thread George Kettleborough

On 22/03/17 15:08, Sven Bretfeld wrote:

Ah, ok I see. Thank you for the reply. Is there any easy way to return
to the old rules? With a wide-screen monitor and Emacs permanently in
fullscreen I don't care about waste of left space.


Have you considered using org-indent-mode? I used to encode the 
indentation in my files too before I discovered that indent mode which 
lets you easily switch the indentation on and off for the entire buffer 
and is just generally easier to use (imo).


George.




Re: [O] ob-shell: using a table variable with bash

2017-03-08 Thread George Kettleborough

On 08/03/17 08:24, Nicolas Goaziou wrote:

I have no objection to this patch, but I think it needs to be
documented, if only as a code comment. IIRC, there is also some
documentation about "ob-shell" on Worg. It would be nice to document
this feature.


I can't actually find any documentation for ob-shell. I had to read the 
source code. I have documented it as a code comment in my patch (with 
proper commit message).


Thanks,

George.

>From 97dadaf0ba0f18772d4d8ac968ea63374937b179 Mon Sep 17 00:00:00 2001
From: George Kettleborough 
Date: Wed, 8 Mar 2017 11:25:37 +
Subject: [PATCH] ob-shell: use old table var behaviour when sep is used

When using the bash shell and an org table is used as a variable, the
default behaviour is to declare it as a bash array. The generic
behaviour is to convert the table to a string with columns separated by
a given separator string. This allows a user to choose the generic
behaviour by declaring the separator using a :separator option to the
code block.
---
 lisp/ob-shell.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el
index 9c22af8..8c7b4f1 100644
--- a/lisp/ob-shell.el
+++ b/lisp/ob-shell.el
@@ -140,7 +140,9 @@ This function is called by `org-babel-execute-src-block'."
 
 (defun org-babel--variable-assignments:bash (varname values &optional sep hline)
   "Represents the parameters as useful Bash shell variables."
-  (if (listp values)
+  ;; we declare org tables as bash array types, unless the user has
+  ;; set the :separator option
+  (if (and (listp values) (null sep))
   (if (and (listp (car values)) (= 1 (length (car values
 	  (org-babel--variable-assignments:bash_array varname values sep hline)
 	(org-babel--variable-assignments:bash_assoc varname values sep hline))
-- 
2.10.1.502.g6598894



[O] ob-shell: using a table variable with bash

2017-03-03 Thread George Kettleborough (EI)

Hello,

I recently updated my org-mode from version 7 (I think) to the latest. 
The behaviour of using a table as a variable in a shell code source 
block has changed. I use to use it like this:


#+BEGIN_SRC sh :results output :var table=synteny-names :separator ,
  IFS=','
  while read col1 col2; do
  # do stuff
  done 

Re: [O] latex export creates "auto" directory

2017-03-03 Thread George Kettleborough (EI)

On 03/03/17 15:55, Takeshi Teshima wrote:

I have a question regarding latex export.

When I export an org-mode to a latex file, a directory named "auto" is
created in the same folder as the tex file.

However, I couldn't find what line in the source code of org-mode
creates this directory.

Does anyone know what causes this, or what variables can be used to
control where the directory is created?



This is actually created by AucTeX. I guess if you open the latex source  
file in emacs then it gets created automatically if you have AucTeX  
installed.


It is documented here:  
https://www.gnu.org/software/auctex/manual/auctex/Parsing-Files.html




Re: [O] Org Clock Timer in Frame Title bug

2012-04-30 Thread George Kettleborough
On Sun, Apr 29 2012, Bastien wrote:
> `global-mode-string' and ̀frame-title-format' are list by default
> and they cannot be customized.  They can be manually set to a string,
> but that's a mistake (okay, `global-mode-string' is a misleading name.)

On my Fedora box, frame-title-format is by default:

(multiple-frames "%b"
 ("" invocation-name "@" system-name))

This is the value even if --no-init-file is used so I don't think this
is distro-specific.

Since the first element in the list is a symbol, the behaviour is to
treat it as a boolean which decides whether the second or third element
is used.  Anything appended to this list is just ignored.

Is this what you mean by frame-title-format being a list by default?  If
so, it's the wrong type of list and we do need to ensure that it's of
the correct form before we can append stuff to the end for display.

global-mode-string, on the other hand, does seem to be of the right type
by default:

("")

Thanks,

George.



Re: [O] Org Clock Timer in Frame Title bug

2012-04-28 Thread George Kettleborough
On Sun, Apr 22 2012, Matt Lundin wrote:
> Mike McLean  writes:
>
>> It appears that there is a small problem with commit
>> 37fafb7b9e4e8e1eeb6b8faa76a1621c28970ef5 (Option for clock and timer to
>> be displayed in frame-title). The default value offrame-title-format in
>> my setup is t and this causes an error when clocking in/out.
>
> I can confirm this bug. The problem is that org-clock-out calls a delq
> on frame-title-format regardless of the value of
> org-clock-clocked-in-display. This is a problem because
> frame-title-format can be either a list or a string. Note: the same
> problem will occur when calling org-clock-in if the value of
> frame-title-format is a string and if org-clock-clocked-in-display is
> set to 'frame-title.

Checking (listp frame-title-format) ensures there will be no error when
calling delq, but it doesn't fix the feature.  If the user's
frame-title-format is not a list then the feature will not work for no
apparent reason.  The same thing goes for global-mode-string too, which
the current release of org-mode modifies.

For the clock and timer display features to work as intended both of
these variables need to be lists with either a string or a list as the
first element.  Note that simply being a list is not enough, it must
contain a string or list as first element.  This format causes the
elements of the list to be treated as mode-line-formats recursively.

The following in both org-clock.el and org-timer.el will ensure both
variables have the correct format to begin with:

(unless (and (listp frame-title-format)
 (or (stringp (first frame-title-format))
 (listp (first frame-title-format
  (setq frame-title-format (list "" frame-title-format)))

(unless (and (listp global-mode-string)
 (or (stringp (first global-mode-string))
 (listp (first global-mode-string
  (setq global-mode-string (list "" global-mode-string)))

It might be better to do this just once in org.el or org-install.el,
since maybe other modules might want to put stuff in the mode-line or
frame-title.

Of course the user or another mode might edit either of the variables to
something bad (like a symbol or string) afterwards.  Maybe this should
be done every time before clock-in/timer-start or any time we wish to
append stuff to either of these lists?

Thanks,

George.



Re: [O] [PATCH] Option for clock and timer to be displayed in frame-title

2012-03-06 Thread George Kettleborough
Hi Bernt,

On Tue, Mar 06 2012, Bernt Hansen wrote:
> I tried this patch at work and it hangs my Emacs session in Windows on
> startup.  It's totally unresponsive and I have to kill the process with
> the task manager.
>
> I think there's an implementation problem here but I don't have any
> other useful information about what it might be.

Thanks for testing the patch.  That's quite alarming and I have no idea
why this would happen.  Can you change the frame title by doing (setq
frame-title-format ...) on Windows emacs normally?  I don't currently
have any Windows boxen to test this on unfortunately.

Also, what emacs version are you running?

Thanks,

George.



Re: [O] [PATCH] Option for clock and timer to be displayed in frame-title

2012-02-29 Thread George Kettleborough
On Tue, Feb 28 2012, Bernt Hansen wrote:
> This patch needs a changelog entry in the commit text and a long
> description would also be appreciated.  The long description allows us
> to see the purpose of the patch and how to use it without the necessity
> to read and parse any of the code changes.

Ok, I've done a changelog entry.  I hope this is what is expected.
(Also fixed a minor bug in original patch and added better documentation
to the new custom variable).

The patch adds options to both org-clock and org-timer regarding how the
current clock/timer is displayed.  Currently they are both displayed in
the mode line.  This is not ideal since if you split your window
horizontally then the mode line becomes quite short so often the clock
is truncated and the timer might not even be visible.

The new options control whether the clock/timer is displayed in the mode
line and/or frame title.  The frame title is usually wasted space for
people running a graphical version of emacs so it is quite useful there
I think.

>From 23b45a824a6118a6aa51ae1ad734747b54ee2f08 Mon Sep 17 00:00:00 2001
From: George Kettleborough 
Date: Wed, 29 Feb 2012 17:04:22 +
Subject: [PATCH] Option for clock and timer to be displayed in frame-title

* lisp/org-clock.el: Add variable org-clock-clocked-in-display which controls
whether the current clock is displayed in the mode line and/or frame title.

* lisp/org-timer.el: Add variable org-timer-display which controls whether the
current timer is displayed in the mode line and/or frame title.

This allows the clock and timer to be displayed in the frame title instead of,
or as well as, the mode line.  This is useful for people with limited space in
the mode line but with ample space in the frame title.
---
 lisp/org-clock.el |   52 
 lisp/org-timer.el |   50 ++
 2 files changed, 86 insertions(+), 16 deletions(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 9206608..b5a9a1b 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -323,6 +323,22 @@ play with them."
   :version "24.1"
   :type 'boolean)
 
+(defcustom org-clock-clocked-in-display 'mode-line
+  "When clocked in for a task, org-mode can display the current
+task and accumulated time in the mode line and/or frame title.
+Allowed values are:
+
+both displays in both mode line and frame title
+mode-linedisplays only in mode line (default)
+frame-title  displays only in frame title
+nil  current clock is not displayed"
+  :group 'org-clock
+  :type '(choice
+	  (const :tag "Mode line" mode-line)
+	  (const :tag "Frame title" frame-title)
+	  (const :tag "Both" both)
+	  (const :tag "None" nil)))
+
 (defvar org-clock-in-prepare-hook nil
   "Hook run when preparing the clock.
 This hook is run before anything happens to the task that
@@ -345,6 +361,8 @@ to add an effort property.")
 (defvar org-mode-line-string "")
 (put 'org-mode-line-string 'risky-local-variable t)
 
+(defvar org-frame-title-string '(" " org-mode-line-string))
+
 (defvar org-clock-mode-line-timer nil)
 (defvar org-clock-idle-timer nil)
 (defvar org-clock-heading) ; defined in org.el
@@ -1170,18 +1188,28 @@ the clocking selection, associated with the letter `d'."
 			 (save-excursion (org-back-to-heading t) (point))
 			 (buffer-base-buffer))
 	(setq org-clock-has-been-used t)
-	(or global-mode-string (setq global-mode-string '("")))
-	(or (memq 'org-mode-line-string global-mode-string)
-		(setq global-mode-string
-		  (append global-mode-string '(org-mode-line-string
+	;; add to mode line
+	(when (or (eq org-clock-clocked-in-display 'mode-line)
+		  (eq org-clock-clocked-in-display 'both))
+	  (or global-mode-string (setq global-mode-string '("")))
+	  (or (memq 'org-mode-line-string global-mode-string)
+		  (setq global-mode-string
+			(append global-mode-string '(org-mode-line-string)
+	;; add to frame title
+	(when (or (eq org-clock-clocked-in-display 'frame-title)
+		  (eq org-clock-clocked-in-display 'both))
+	  (or (memq 'org-frame-title-string frame-title-format)
+		  (setq frame-title-format
+			(append frame-title-format '(org-frame-title-string)
 	(org-clock-update-mode-line)
 	(when org-clock-mode-line-timer
 	  (cancel-timer org-clock-mode-line-timer)
 	  (setq org-clock-mode-line-timer nil))
-	(setq org-clock-mode-line-timer
-		  (run-with-timer org-clock-update-period
-  org-clock-update-period
-  'org-clock-update-mode-line))
+	(when org-clock-clocked-in-display
+	  (setq org-clock-mode-line-timer
+		(run-with-timer org-clock-update-period
+org-clock-update