Re: Filter for HTML footnotes?

2022-03-05 Thread Juan Manuel Macías
M. ‘quintus’ Gülker writes:

> I recently discovered export filters and found some useful applications
> for them. For instance, the scientific domain I work in (law) uses
> footnote citations, and in these footnotes we abbreviate some words
> which would otherwise be written out in ordinary text, like name
> particles. Since I use org-cite these footnotes are automatically
> generated. So what I did was to write a filter which abbreviates these
> words on export in footnotes. I added the filter function to both
> org-export-filter-footnote-definition-functions and
> org-export-filter-footnote-reference-functions and indeed, when I export
> to LaTeX or ODT it does its job just fine. However, when I export to
> HTML instead, it does not. When I looked at the text passed to the
> filter when exporting as HTML, it turned out what the function receives
> is not the content of the footnote, but only the markup for the footnote
> number. That came a bit by surprise.

> So, what is the correct way to target the content of a footnote in a
> filter across backends?

Hi,

I think a function for `org-export-filter-parse-tree-functions' would
work better here. For example, this function replaces "lorem ipsum" with
"foo" in all footnote definitions:

#+BIND: org-export-filter-parse-tree-functions (fnt-filter-replace)

#+begin_src emacs-lisp :exports results :results none
  (defun fnt-filter-replace (tree backend info)
(org-element-map tree 'footnote-definition
  (lambda (fnt)
(let* ((contents (org-element-interpret-data
  (org-element-contents fnt)))
   (contents-new (with-temp-buffer
   (insert contents)
   (save-excursion
 (goto-char (point-min))
 (while (re-search-forward "lorem ipsum" nil t)
   (replace-match "foo" t nil)))
   (org-element-parse-buffer
  (apply #'org-element-set-contents
 fnt
 (list contents-new
  info)
tree)
#+end_src

Best regards,

Juan Manuel 




Re: debugging latex preview

2022-03-05 Thread Alain . Cochard
Eric S Fraga writes on Fri  4 Mar 2022 16:59:
 > Quick question: what is the best (or any) way to debug LaTeX preview in
 > org mode?  All of sudden, my previous are not shrink-wrapped (hope that
 > makes sense).  I cannot think of anything I changed although I'm sure I
 > did change something...
 > 
 > Suggestions welcome before I delve into the elisp code!

Maybe this is not at all appropriate in this case, but I'm risking it:
why not bug-hunter?


-- 
EOST (École et Observatoire des Sciences de la Terre) 
ITE (Institut Terre & Environnement) | alain.coch...@unistra.fr
5 rue René Descartes   [bureau 106]  | Phone: +33 (0)3 68 85 50 44 
F-67084 Strasbourg Cedex, France | [ slot available for rent ]




Move or rename a file in a link

2022-03-05 Thread Juan Manuel Macías
Hi all,

I have written this simple function to move or rename a destination file
in an external link at point. I share it here in case it is useful to
someone.

Best regards,

Juan Manuel 

#+begin_src emacs-lisp
(defun my-org-replace-link-file (from to)
  (save-excursion
(goto-char (point-min))
(while (re-search-forward org-bracket-link-regexp nil t)
  (when (string-match-p from (match-string 1))
(replace-match (concat "[[file:" to "]]"))

(defun my-org-rename-link-file-at-point ()
  "Rename or move a file in an external link at point and
  update the link path"
  (interactive)
  (let* ((curr-dir (abbreviate-file-name default-directory))
 (current-path (org-element-property :path (org-element-context)))
 (new-path (read-file-name "Rename file at point to: " current-path)))
(rename-file current-path new-path)
(message (concat "moved to: " new-path))
(if (directory-name-p new-path)
(setq new-path (concat new-path (file-name-nondirectory current-path)))
  (setq new-path new-path))
(my-org-replace-link-file current-path
  (replace-regexp-in-string curr-dir "" new-path

#+end_src



Filter for HTML footnotes?

2022-03-05 Thread M . ‘quintus’ Gülker
Dear list,

I recently discovered export filters and found some useful applications
for them. For instance, the scientific domain I work in (law) uses
footnote citations, and in these footnotes we abbreviate some words
which would otherwise be written out in ordinary text, like name
particles. Since I use org-cite these footnotes are automatically
generated. So what I did was to write a filter which abbreviates these
words on export in footnotes. I added the filter function to both
org-export-filter-footnote-definition-functions and
org-export-filter-footnote-reference-functions and indeed, when I export
to LaTeX or ODT it does its job just fine. However, when I export to
HTML instead, it does not. When I looked at the text passed to the
filter when exporting as HTML, it turned out what the function receives
is not the content of the footnote, but only the markup for the footnote
number. That came a bit by surprise.

So, what is the correct way to target the content of a footnote in a
filter across backends?

Org mode version 9.5 (release_9.5-484-g98588e @ 
/home/quintus/.emacs.d/org-mode/lisp/)

  -quintus

--
Dipl.-Jur. M. Gülker | https://mg.guelker.eu | PGP: Siehe Webseite
Passau, Deutschland  | kont...@guelker.eu| O<



[BUG] Scheduled task shows up wrong day in agenda [9.5.2 (release_9.5.2-22-g33543d @ /usr/local/share/emacs/29.0.50/lisp/org/)]

2022-03-05 Thread Jeffrey DeLeo


Single org file "foobar.org", containing one task scheduled for
Sunday. It is displayed on agenda for Saturday. I build my own emacs,
which includes org, on OS Ubuntu 20.04.

foobar.org contents:

* Tasks
** TODO Something
SCHEDULED: <2022-03-06 Sun>

Agenda Displays:

Day-agenda (W09):
Saturday5 March 2022
  foobar: Scheduled:  TODO Something



Emacs  : GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, 
cairo version 1.16.0)
 of 2022-02-28
Package: Org mode version 9.5.2 (release_9.5.2-22-g33543d @ 
/usr/local/share/emacs/29.0.50/lisp/org/)

current state:
==
(setq
 org-link-elisp-confirm-function 'yes-or-no-p
 org-directory "./"
 org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn 
ENTRY)"]
 org-agenda-files '("foobar.org")
 org-export-before-parsing-hook '(org-attach-expand-links)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers 
org-cycle-show-empty-lines
  org-optimize-window-after-visibility-change)
 org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook 
change-major-mode-hook org-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-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)
   ("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 org-link--open-shell)
   ("news" :follow
#[514 "\301\300\302Q\"\207" ["news" browse-url ":"] 6 
"\n\n(fn URL ARG)"])
   ("mailto" :follow
#[514 "\301\300\302Q\"\207" ["mailto" browse-url ":"] 6 
"\n\n(fn URL ARG)"])
   ("https" :follow
#[514 "\301\300\302Q\"\207" ["https" browse-url ":"] 6 
"\n\n(fn URL ARG)"])
   ("http" :follow
#[514 "\301\300\302Q\"\207" ["http" browse-url ":"] 6 
"\n\n(fn URL ARG)"])
   ("ftp" :follow
#[514 "\301\300\302Q\"\207" ["ftp" browse-url ":"] 6 
"\n\n(fn URL ARG)"])
   ("help" :follow org-link--open-help :store 
org-link--store-help)
   ("file" :complete org-link-complete-file) ("elisp" 
:follow org-link--open-elisp))
 org-metaup-hook '(org-babel-load-in-session-maybe)
 )