emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Harald Judt <h.judt@gmx.at>
To: emacs-orgmode@gnu.org
Subject: [BUG] org-context called from link in org-agenda entry returns wrong values [9.5 (9.5-g0a86ad @ /home/.emacs.d/elpa/org-9.5/)]
Date: Wed, 6 Oct 2021 11:44:58 +0200	[thread overview]
Message-ID: <97c31832-9dce-c52f-038e-ccc80157b62e@gmx.at> (raw)

[-- Attachment #1.1.1: Type: text/plain, Size: 10604 bytes --]


I am using this function to copy links from the agenda to the clipboard:

(defun my-copy-org-url ()
     (let* ((link-info (assoc :link (org-context)))
            (text (when link-info
                     (or (cadr link-info) (point-min))
                     (or (caddr link-info) (point-max))))))
       (if (not text)
           (error "Point not in an org link.")
         (string-match org-bracket-link-regexp text)
         (kill-new (url-encode-url (substring text (match-beginning 1) 
(match-end 1))))
         (message "Org link URL copied to clipboard."))))

This indeed worked fine with previous versions of org, but recently started
to fail to extract the link. Example entry to put into your agenda
to test this:

* TODO Header with [[https://orgmode.org/][Link]]
SCHEDULED: <2021-10-06 Mi 12:00>

Now the function above should extract "https://orgmode.org/", but
instead the text extracted is "Lin".

Stepping through the function with edefun-debug tells me that
org-context returns the wrong values ((:link begin end)).

Note that the function seems to work fine if I call it from a normal
org file (not from the agenda) interactively, and I get ((:item i j)
(:link x y)) with the correct link.

(Note in the following section I have edited some paths and the list of my org 
files for privacy reasons, but that shouldn't be relevant to this issue.)

Emacs  : GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.29, 
cairo version 1.16.0)
  of 2021-09-27
Package: Org mode version 9.5 (9.5-g0a86ad @ /home/.emacs.d/elpa/org-9.5/)

current state:
  org-roam-db-location "~/.cache/emacs/org-roam.db"
  org-src-mode-hook '(org-src-babel-configure-edit-buffer 
  org-capture-prepare-finalize-hook '(org-roam-capture--install-finalize-h)
  org-link-shell-confirm-function 'yes-or-no-p
  org-metadown-hook '(org-babel-pop-to-session-maybe)
  org-roam-db-node-include-function '(closure (t) nil t)
  org-refile-targets '((org-agenda-files :maxlevel . 2))
  org-table-convert-region-max-lines 2000
  org-roam-mode-hook '(org-roam-bibtex-mode)
  org-roam-bibtex-mode t
  org-agenda-files '("snip.org")
  org-reveal-start-hook '(org-decrypt-entry)
  org-archive-location "~/work/org/archive/%s_archive::"
  org-mode-hook '(org-bullets-mode org-clock-load
                  (lambda nil (add-hook 'before-save-hook 
'my-org-add-ids-to-headlines-in-file nil 'local))
                  #[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
                  #[0 "\301\211\x10\207" [imenu-create-index-function 
org-imenu-get-tree] 2] whitespace-mode
  org-clock-persist 'history
  org-archive-hook '(org-attach-archive-delete-maybe)
  org-roam-capture-new-node-hook '(orb--insert-captured-ref-h)
  org-confirm-elisp-link-function 'yes-or-no-p
  org-journal-mode-hook '((closure
org-journal-mode-syntax-table view-exit-action t)
                           nil (add-hook org-journal-encrypt-on 
'org-journal-encryption-hook nil t))
                          (lambda nil (add-hook org-journal-encrypt-on 
'org-journal-encryption-hook nil t)))
  org-agenda-before-write-hook '(org-agenda-add-entry-text)
  org-metaup-hook '(org-babel-load-in-session-maybe)
  org-bibtex-headline-format-function #[257 "\300\x01\236A\207" [:title] 3 
"\n\n(fn ENTRY)"]
  org-log-reschedule 'note
  org-babel-pre-tangle-hook '(save-buffer)
  org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
  org-babel-load-languages '((emacs-lisp . t) (shell . t) (python . t) (sed . 
t) (awk . t) (sql . t) (ditaa . t))
  org-log-done 'time
  org-journal-date-format "%Y-%m-%d %A"
  org-agenda-span 'fortnight
  org-agenda-loop-over-headlines-in-active-region nil
  org-roam-find-file-hook '(org-roam-buffer--setup-redisplay-h 
  org-catch-invisible-edits t
  org-occur-hook '(org-first-headline-recenter)
  org-log-into-drawer t
  org-ditaa-jar-path "/usr/share/ditaa/lib/ditaa.jar"
  org-ref-bibtex-assoc-pdf-with-entry-move-function 'rename-file
  org-agenda-include-diary t
  org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers 
  org-speed-command-hook '(org-speed-command-activate 
  org-roam-node-annotation-function 'org-roam-node-read--annotation
  org-clock-persist-file "~/.cache/emacs/org-clock-save.el"
  org-roam-ui-browser-function 'browse-url
  org-roam-ref-annotation-function 'org-roam-ref-read--annotation
  org-journal-dir "~/work/org/journal"
  org-babel-tangle-lang-exts '(("awk" . "awk") ("sed" . "sed") ("python" . 
"py") ("emacs-lisp" . "el")
                               ("elisp" . "el"))
  org-ref-pdf-to-bibtex-function 'copy-file
  org-refile-allow-creating-parent-nodes 'confirm
  org-export-before-parsing-hook '(org-attach-expand-links)
  org-journal-created-property-timestamp-format "%Y-%m-%d"
  org-id-locations-file "~/.cache/emacs/.org-id-locations"
  org-capture-use-agenda-date t
  org-confirm-shell-link-function 'yes-or-no-p
  org-link-parameters '(("attachment" :follow org-attach-follow :complete 
                        ("roam" :follow org-roam-link-follow-link) ("id" 
:follow org-id-open)
                        ("eww" :follow org-eww-open :store org-eww-store-link)
                        ("rmail" :follow org-rmail-open :store 
                        ("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)
                        ("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)
                        ("nov" :follow nov-org-link-follow :store 
                        ("doi" :follow org-link-doi-open :export 
                        ("bibtex" :follow org-bibtex-open :store 
                        ("treemacs" :store treemacs-store-org-link) 
("file+sys") ("file+emacs")
                        ("shell" :follow org-link--open-shell)
                        ("news" :follow
                         #[514 "\301\300\302\x04Q\x02\"\207" ["news" browse-url ":"] 
6 "\n\n(fn URL ARG)"])
                        ("mailto" :follow
                         #[514 "\301\300\302\x04Q\x02\"\207" ["mailto" browse-url 
":"] 6 "\n\n(fn URL ARG)"])
                        ("https" :follow
                         #[514 "\301\300\302\x04Q\x02\"\207" ["https" browse-url 
":"] 6 "\n\n(fn URL ARG)"])
                        ("http" :follow
                         #[514 "\301\300\302\x04Q\x02\"\207" ["http" browse-url ":"] 
6 "\n\n(fn URL ARG)"])
                        ("ftp" :follow #[514 "\301\300\302\x04Q\x02\"\207" ["ftp" 
browse-url ":"] 6 "\n\n(fn URL ARG)"])
                        ("help" :follow org-link--open-help :store 
                        ("file" :complete org-link-complete-file) ("elisp" 
:follow org-link--open-elisp))
  org-capture-templates '(("p" "Private templates")
                          ("pt" "TODO entry" entry (file+headline 
"~/work/org/home.org" "Inbox")
                           (file "~/work/org/templates/private/todo.org") 
:empty-lines-before 1)
                          ("pd" "Daily plan entry" plain (file+olp+datetree 
"~/work/org/templates/private/plan-entry.org") :empty-lines 0 :immediate-finish t
                           :jump-to-captured t :time-prompt t)
  org-link-elisp-confirm-function 'yes-or-no-p
  org-roam-db-autosync-mode t
  org-capture-after-finalize-hook '(orb-make-notes-cache)
  org-clock-into-drawer "CLOCKING"
  org-roam-directory "~/work/org/roam/"
  org-journal-file-format "%Y-%m-%d.org"
  org-ditaa-eps-jar-path "/home/.emacs.d/elpa/contrib/scripts/DitaaEps.jar"
  org-confirm-babel-evaluate nil
  org-agenda-custom-commands '(("n" "Agenda and all TODOs" ((agenda "" nil) 
(alltodo "" nil)) nil)
                               ("r" "Agenda and all TODOs without recurring tasks"
                                ((agenda ""
                                  ((org-agenda-overriding-header "Agenda 
without recurring tasks")
                                   (org-agenda-include-diary nil)
                                 (alltodo "" nil))
                               ("w" "Agenda and all TODOs (work-related only)" 
agenda ""
                                ((org-agenda-overriding-header "Work Agenda 
and work-related TODOs ")
                                 (org-agenda-include-diary t) 
(org-agenda-tag-filter-preset '("-home")))
  org-ref-notes-function 'orb-org-ref-edit-note

Best regards,

`Experience is the best teacher.'

Fingerprint: E073 6DD8 FF40 9CF2 0665 11D4 4FFF AB21 B858 0ABD

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 659 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

             reply	other threads:[~2021-10-06 16:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06  9:44 Harald Judt [this message]
2021-10-07  4:10 ` [BUG] org-context called from link in org-agenda entry returns wrong values [9.5 (9.5-g0a86ad @ /home/.emacs.d/elpa/org-9.5/)] Ihor Radchenko
2021-10-08 11:38   ` Harald Judt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=97c31832-9dce-c52f-038e-ccc80157b62e@gmx.at \
    --to=h.judt@gmx.at \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).