Re: [O] org-store-link calls external link type store functions twice?
Hi, I made a small example where I added an external link type, counter that always works and updates a counter. It is quite crude but shows my point: (org-add-link-type counter 'ra/org-counter-open) (add-hook 'org-store-link-functions 'ra/org-counter-store-link) (defun ra/org-counter-store-link () Store a dummy counter link. (if (boundp 'counter) (setq counter (1+ counter)) (setq counter 1)) (let* ((link (concat counter: (number-to-string counter))) (desc (format Calls to ra/org-counter-store-link: %d counter))) (org-store-link-props :type counter :link link :description desc))) (defun ra/org-counter-open (path) Print and reset the counter. (message (format Calls to ra/org-counter-store-link: %d. Resetting counter. counter)) (makunbound 'counter)) Running org-capture with the above external link type will result in counter to be set to 2 before inserting the link in the *Capture* buffer. I have also tried the example A.3 Adding hyperlinks types in the manual -- same result when debugging org-man-store-link. In the definition of org-store-link the interesting part is paste below. I have marked the calls to external link types store function, ie ra/org-counter-store-link above. ; Store a link using an external link type ((and (not (equal arg '(16))) (setq sfuns (delq nil (mapcar (lambda (f) (let (fs) (if (funcall f) (push f fs ;;; -- first call to ra/org-counter-store-link org-store-link-functions)) sfunsn (mapcar (lambda (fu) (symbol-name (car fu))) sfuns)) (or (and (cdr sfuns) (funcall (intern (completing-read Which function for creating the link? sfunsn t (car sfunsn) (funcall (caar sfuns))) ;;; -- second call to ra/org-counter-store-link (setq link (plist-get org-store-link-plist :link) desc (or (plist-get org-store-link-plist :description) link This problem only shows up in version 8 of org-mode, not version 7. Please let me know if I can provide you with even more information. Thanks for listening, /robert On Tue, May 14, 2013 at 10:41 AM, Bastien b...@gnu.org wrote: Hi Robert, Robert Adesam rob...@adesam.se writes: I am not sure this is a bug but in version 8.x storing a link using an external link type, org-store-link seems to call the external link type's store function twice... I noticed this as I use an external link type that asynchronous updates an external filedatabase and started to get random file lock errors -- the org-store-link second call to the external link type's store function sometimes came too quickly after the first one. :-) Also, I do not have this problem in version 7.x of orgmode. Instead of reverting back to a previous version of orgmode I started to investigate -- attaching a patch that seems to help me anyway. It's not that well tested and maybe, as I am not that familiar with everything going on when storing a link using an external link type, it will break other things... I re-read `org-store-link' and I don't see how the external function can be called twice... maybe you can give more details on what this external function looks like, when it is called (within a script or something), etc? Thanks! -- Bastien
[O] org-store-link calls external link type store functions twice?
Hi fellow orgmoders, I am not sure this is a bug but in version 8.x storing a link using an external link type, org-store-link seems to call the external link type's store function twice... I noticed this as I use an external link type that asynchronous updates an external filedatabase and started to get random file lock errors -- the org-store-link second call to the external link type's store function sometimes came too quickly after the first one. :-) Also, I do not have this problem in version 7.x of orgmode. Instead of reverting back to a previous version of orgmode I started to investigate -- attaching a patch that seems to help me anyway. It's not that well tested and maybe, as I am not that familiar with everything going on when storing a link using an external link type, it will break other things... yours, /robert PS. I will not file a formal bug report as it might not be a bug, just me getting upset of a probable superfluous funcall... M-x version: GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.6.4) of 2013-04-14 on marid, modified by Debian M-x org-version: Org-mode version 8.0.2 (8.0.2-10-g3e1d83-elpa @ /home/robert/.emacs.d/elpa/org-20130506/) org.el.patch Description: Binary data
[O] Report on package Org-mode version N/A (N/A @ c:/cygwin/usr/local/share/emacs/site-lisp/org/)
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 http://orgmode.org/manual/Feedback.html#Feedback Your bug report will be posted to the Org-mode mailing list. The variable org-version not set properly in orgmode 7.9 installing on emacs 24.1 with cygwin on windows 7, suspect the new build system as this was a non-issue with earlier releases... yours, /robert Emacs : GNU Emacs 24.1.1 (i386-mingw-nt6.1.7601) of 2012-06-02 on MARVIN Package: Org-mode version N/A (N/A @ c:/cygwin/usr/local/share/emacs/site-lisp/org/) current state: == (setq org-export-blocks '((src org-babel-exp-src-block nil) (export-comment org-export-blocks-format-comment t) (ditaa org-export-blocks-format-ditaa nil) (dot org-export-blocks-format-dot nil)) org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-safely-maybe) org-archive-location archive/%s.old::* Archive org-export-preprocess-before-selecting-backend-code-hook '(org-beamer-select-beamer-code) org-tab-first-hook '(org-hide-block-toggle-maybe org-src-native-tab-command-maybe org-babel-hide-result-toggle-maybe org-babel-header-arg-expand) org-refile-targets '((someday.org :level . 1) (inbox.org :level . 1) (tasks.org :level . 1) (projects.org :maxlevel . 2) (mlt.org :level . 1)) org-modules '(org-bbdb org-bibtex org-crypt) org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers org-cycle-show-empty-lines org-optimize-window-after-visibility-change) org-agenda-custom-commands '((i Inbox entries tags-todo CATEGORY=\Stuff\) (n MLT entries ((tags-todo +mlt|CATEGORY=\MLT\|CATEGORY=\MLT PC\|CATEGORY=\MLT Notes\) (tags +mlt+TODO=\DONE\|+mlt+TODO=\CANCELLED\|+mlt+TODO=\DEFERRED\|CATEGORY=\MLT\+TODO=\DONE\|CATEGORY=\MLT\+TODO=\CANCELLED\|CATEGORY=\MLT\+TODO=\DEFERRED\|CATEGORY=\MLT PC\+TODO=\DONE\|CATEGORY=\MLT PC\+TODO=\CANCELLED\|CATEGORY=\MLT PC\+TODO=\DEFERRED\|CATEGORY=\MLT Notes\+TODO=\DONE\|CATEGORY=\MLT Notes\+TODO=\CANCELLED\|CATEGORY=\MLT Notes\+TODO=\DEFERRED\))) (w todo WAITING) (d todo DONE|CANCELLED|DEFERRED)) org-agenda-before-write-hook '(org-agenda-add-entry-text) org-speed-command-hook '(org-speed-command-default-hook org-babel-speed-command-hook) org-email-link-description-format Email %c: %.50s org-link-mailto-program '(vm-mail %a %s) org-babel-pre-tangle-hook '(save-buffer) org-occur-hook '(org-first-headline-recenter) org-export-interblocks '((src org-babel-exp-non-block-elements)) org-cycle-separator-lines 0 org-metaup-hook '(org-babel-load-in-session-maybe) org-reveal-start-hook '(org-decrypt-entry) org-confirm-elisp-link-function 'yes-or-no-p org-export-latex-format-toc-function 'org-export-latex-format-toc-default org-log-into-drawer LOGBOOK org-default-notes-file c:/Users/robert/Dropbox/gtd/inbox.org org-columns-default-format %60ITEM %TODO %TAGS %6effort(EFFORT){:} org-export-preprocess-before-normalizing-links-hook '(org-remove-file-link-modifiers) org-tag-alist '((@home . 104) (@office . 111) (@phone . 112) (@cms . 119) (@computer . 99) (@errands . 101) (@blog . 98) (@ltlunch . 108) (@2020 . 50) (someday . 115) (@gul . 103) (flov . 102) (mlt . 109) (dtl . 100)) org-global-properties '((effort_ALL . 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 8:00)) org-clock-out-hook '(org-clock-remove-empty-clock-drawer) org-publish-project-alist '((org-web :base-directory ~/web :base-extension org :publishing-directory /Volumes/robert/.www :recursive t :publishing-function org-publish-org-to-html :headline-levels 4 :auto-preamble t) (org-web-static :base-directory ~/web :base-extension css\\|js\\|png\\|jpg\\|jpeg\\|gif\\|pdf\\|mp3\\|ogg\\|swf :publishing-directory /Volumes/robert/.www :recursive t :publishing-function org-publish-attachment) (web :components (org-web org-web-static))) org-agenda-include-diary t org-export-latex-classes '((article \\documentclass{article}\n\\usepackage[utf8x]{inputenc}\n\\usepackage{graphicx}\n\\usepackage{longtable}\n\\usepackage{hyperref}\n\\usepackage[swedish]{babel} (\\section{%s} . \\section*{%s}) (\\subsection{%s} . \\subsection*{%s}) (\\subsubsection{%s} . \\subsubsection*{%s}) (\\paragraph{%s} . \\paragraph*{%s}) (\\subparagraph{%s} . \\subparagraph*{%s}))) org-export-first-hook '(org-beamer-initialize-open-trackers) org-mode-hook '(#[nil \300\301\302\303\304$\207 [org-add-hook change-major-mode-hook org-show-block-all append local] 5] #[nil \300\301\302\303\304$\207 [org-add-hook change-major-mode-hook org-babel-show-result-all append local] 5] org-babel-result-hide-spec org-babel-hide-all-hashes (lambda nil (auto-fill-mode 1) (local-set-key (kbd C-c t) (quote org-todo)) (local-set-key (kbd C-c e) (quote org-set-effort)) (local-set-key (kbd C-c i) (quote