emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Recently master branch commit breaks open file: link
@ 2020-02-24  6:38 stardiviner
  2020-02-24  8:41 ` Bastien
  0 siblings, 1 reply; 11+ messages in thread
From: stardiviner @ 2020-02-24  6:38 UTC (permalink / raw)
  To: Org Mode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


When I open a link like this:

#+begin_src org
[[file:~/Org/Tasks/Computer Todos.org::*TODO 厉害的人是怎么分析问题的?][厉害的人是怎么分析问题的?]]
#+end_src

I =[M-x toggle-debug-on-error]= got following stacktrace:

#+begin_example
Debugger entered--Lisp error: (file-missing "Reading directory" "No such file or directory" "/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My...")
  access-file("/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My..." "Reading directory")
  #f(compiled-function (file switches &optional wildcard full-directory-p) "Insert directory listing for FILE, formatted according to SWITCHES.\nLeaves point after the inserted text.\nSWITCHES may be a string of options, or a list of strings\nrepresenting individual options.\nOptional third arg WILDCARD means treat FILE as shell wildcard.\nOptional fourth arg FULL-DIRECTORY-P means file is a directory and\nswitches do not contain `d', so that a full listing is expected.\n\nThis works by running a directory listing program\nwhose name is in the variable `insert-directory-program'.\nIf WILDCARD, it also runs the shell specified by `shell-file-name'.\n\nWhen SWITCHES contains the long `--dired' option, this function\ntreats it specially, for the sake of dired.  However, the\nnormally equivalent short `-D' option is just passed on to\n`insert-directory-program', as any other option." #<bytecode 0x1fd4cbe79ddd>)("/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My..." "--dired -al" t nil)
  ls-lisp--insert-directory(#f(compiled-function (file switches &optional wildcard full-directory-p) "Insert directory listing for FILE, formatted according to SWITCHES.\nLeaves point after the inserted text.\nSWITCHES may be a string of options, or a list of strings\nrepresenting individual options.\nOptional third arg WILDCARD means treat FILE as shell wildcard.\nOptional fourth arg FULL-DIRECTORY-P means file is a directory and\nswitches do not contain `d', so that a full listing is expected.\n\nThis works by running a directory listing program\nwhose name is in the variable `insert-directory-program'.\nIf WILDCARD, it also runs the shell specified by `shell-file-name'.\n\nWhen SWITCHES contains the long `--dired' option, this function\ntreats it specially, for the sake of dired.  However, the\nnormally equivalent short `-D' option is just passed on to\n`insert-directory-program', as any other option." #<bytecode 0x1fd4cbe79ddd>) "/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My..." "--dired -al" t nil)
  apply(ls-lisp--insert-directory #f(compiled-function (file switches &optional wildcard full-directory-p) "Insert directory listing for FILE, formatted according to SWITCHES.\nLeaves point after the inserted text.\nSWITCHES may be a string of options, or a list of strings\nrepresenting individual options.\nOptional third arg WILDCARD means treat FILE as shell wildcard.\nOptional fourth arg FULL-DIRECTORY-P means file is a directory and\nswitches do not contain `d', so that a full listing is expected.\n\nThis works by running a directory listing program\nwhose name is in the variable `insert-directory-program'.\nIf WILDCARD, it also runs the shell specified by `shell-file-name'.\n\nWhen SWITCHES contains the long `--dired' option, this function\ntreats it specially, for the sake of dired.  However, the\nnormally equivalent short `-D' option is just passed on to\n`insert-directory-program', as any other option." #<bytecode 0x1fd4cbe79ddd>) ("/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My..." "--dired -al" t nil))
  insert-directory("/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My..." "--dired -al" t nil)
  dired-insert-directory("/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My..." "-al" nil t t)
  dired-readin-insert()
  dired-readin()
  dired-internal-noselect("~/Org/Wiki/Thought/Data/Manuals/My Thought Manuals..." nil)
  dired-noselect("~/Org/Wiki/Thought/Data/Manuals/My Thought Manuals..." nil)
  #f(compiled-function (dirname &optional switches) "\"Edit\" directory DIRNAME--delete, rename, print, etc. some files in it.\nOptional second argument SWITCHES specifies the `ls' options used.\n(Interactively, use a prefix argument to be able to specify SWITCHES.)\n\nIf DIRNAME is a string, Dired displays a list of files in DIRNAME (which\nmay also have shell wildcards appended to select certain files).\n\nIf DIRNAME is a cons, its first element is taken as the directory name\nand the rest as an explicit list of files to make directory entries for.\nIn this case, SWITCHES are applied to each of the files separately, and\ntherefore switches that control the order of the files in the produced\nlisting have no effect.\n\n\\<dired-mode-map>You can flag files for deletion with \\[dired-flag-file-deletion] and then\ndelete them by typing \\[dired-do-flagged-delete].\nType \\[describe-mode] after entering Dired for more info.\n\nIf DIRNAME is already in a Dired buffer, that buffer is used without refresh." (interactive (dired-read-dir-and-switches "")) #<bytecode 0x155ef9d2f645>)("~/Org/Wiki/Thought/Data/Manuals/My Thought Manuals..." nil)
  ls-lisp--dired(#f(compiled-function (dirname &optional switches) "\"Edit\" directory DIRNAME--delete, rename, print, etc. some files in it.\nOptional second argument SWITCHES specifies the `ls' options used.\n(Interactively, use a prefix argument to be able to specify SWITCHES.)\n\nIf DIRNAME is a string, Dired displays a list of files in DIRNAME (which\nmay also have shell wildcards appended to select certain files).\n\nIf DIRNAME is a cons, its first element is taken as the directory name\nand the rest as an explicit list of files to make directory entries for.\nIn this case, SWITCHES are applied to each of the files separately, and\ntherefore switches that control the order of the files in the produced\nlisting have no effect.\n\n\\<dired-mode-map>You can flag files for deletion with \\[dired-flag-file-deletion] and then\ndelete them by typing \\[dired-do-flagged-delete].\nType \\[describe-mode] after entering Dired for more info.\n\nIf DIRNAME is already in a Dired buffer, that buffer is used without refresh." (interactive (dired-read-dir-and-switches "")) #<bytecode 0x155ef9d2f645>) "~/Org/Wiki/Thought/Data/Manuals/My Thought Manuals...")
  apply(ls-lisp--dired #f(compiled-function (dirname &optional switches) "\"Edit\" directory DIRNAME--delete, rename, print, etc. some files in it.\nOptional second argument SWITCHES specifies the `ls' options used.\n(Interactively, use a prefix argument to be able to specify SWITCHES.)\n\nIf DIRNAME is a string, Dired displays a list of files in DIRNAME (which\nmay also have shell wildcards appended to select certain files).\n\nIf DIRNAME is a cons, its first element is taken as the directory name\nand the rest as an explicit list of files to make directory entries for.\nIn this case, SWITCHES are applied to each of the files separately, and\ntherefore switches that control the order of the files in the produced\nlisting have no effect.\n\n\\<dired-mode-map>You can flag files for deletion with \\[dired-flag-file-deletion] and then\ndelete them by typing \\[dired-do-flagged-delete].\nType \\[describe-mode] after entering Dired for more info.\n\nIf DIRNAME is already in a Dired buffer, that buffer is used without refresh." (interactive (dired-read-dir-and-switches "")) #<bytecode 0x155ef9d2f645>) "~/Org/Wiki/Thought/Data/Manuals/My Thought Manuals...")
  dired("~/Org/Wiki/Thought/Data/Manuals/My Thought Manuals...")
  (if (string-match "[*?{]" (file-name-nondirectory path)) (dired path) (let* ((option (and (string-match "::\\(.*\\)\\'" path) (match-string 1 path))) (path (if (not option) path (substring path 0 (match-beginning 0))))) (apply #'org-open-file path arg (cond ((not option) nil) ((string-match-p "\\`[0-9]+\\'" option) (list (string-to-number option))) (t (list nil option))))))
  org-link-open-as-file("~/Org/Wiki/Thought/Data/Manuals/My Thought Manuals..." nil)
  (let* ((option (org-element-property :search-option link)) (path (if option (concat path "::" option) path))) (org-link-open-as-file path (let* ((val (org-element-property :application link))) (cond (arg arg) ((equal val '"emacs") 'emacs) ((equal val '"sys") 'system) (t nil)))))
  (cond ((equal type '"file") (let* ((option (org-element-property :search-option link)) (path (if option (concat path "::" option) path))) (org-link-open-as-file path (let* ((val (org-element-property :application link))) (cond (arg arg) ((equal val ...) 'emacs) ((equal val ...) 'system) (t nil)))))) ((member type '("radio" "fuzzy" "custom-id" "coderef")) (if (run-hook-with-args-until-success 'org-open-link-functions path) nil (if (not arg) (org-mark-ring-push) (switch-to-buffer-other-window (org-link--buffer-for-internals))) (let ((destination (save-excursion (save-restriction ... ... ...)))) (if (and (<= (point-min) destination) (>= (point-max) destination)) nil (widen)) (goto-char destination)))) (t (let ((f (org-link-get-parameter type :follow))) (if (functionp f) (progn (condition-case nil (funcall (org-link-get-parameter type :follow) path arg) (wrong-number-of-arguments (funcall ... path))))))))
  (let ((type (org-element-property :type link)) (path (org-element-property :path link))) (cond ((equal type '"file") (let* ((option (org-element-property :search-option link)) (path (if option (concat path "::" option) path))) (org-link-open-as-file path (let* ((val ...)) (cond (arg arg) (... ...) (... ...) (t nil)))))) ((member type '("radio" "fuzzy" "custom-id" "coderef")) (if (run-hook-with-args-until-success 'org-open-link-functions path) nil (if (not arg) (org-mark-ring-push) (switch-to-buffer-other-window (org-link--buffer-for-internals))) (let ((destination (save-excursion ...))) (if (and (<= ... destination) (>= ... destination)) nil (widen)) (goto-char destination)))) (t (let ((f (org-link-get-parameter type :follow))) (if (functionp f) (progn (condition-case nil (funcall ... path arg) (wrong-number-of-arguments ...))))))))
  org-link-open((link (:type "file" :path "~/Org/Wiki/Thought/Data/Manuals/My Thought Manuals..." :format bracket :raw-link "file:~/Org/Wiki/Thought/Data/Manuals/My Thought Ma..." :application nil :search-option "*厉害的人是怎么分析问题的?" :begin 401398 :end 401511 :contents-begin 401496 :contents-end 401509 :post-blank 0 :parent (paragraph (:begin 401398 :end 401513 :contents-begin 401398 :contents-end 401512 :post-blank 1 :post-affiliated 401398 :parent nil)))) nil)
  (cond ((not type) (user-error "No link found")) ((memq type '(comment comment-block node-property keyword)) (call-interactively #'org-open-at-point-global)) ((memq type '(headline inlinetask)) (org-match-line org-complex-heading-regexp) (let ((tags-beg (match-beginning 5)) (tags-end (match-end 5))) (if (and tags-beg (>= (point) tags-beg) (< (point) tags-end)) (org-tags-view arg (save-excursion (let* (... ...) (buffer-substring ... ...)))) (let* ((val (org-offer-links-in-entry ... ... arg))) (if (consp val) (let* (...) (if ... ... ...)) nil))))) ((or (eq type 'footnote-reference) (and (eq type 'footnote-definition) (save-excursion (skip-chars-forward " \11") (let ((begin ...)) (if begin (< ... begin) (= ... ...)))))) (org-footnote-action)) ((and (eq type 'planning) (org-in-regexp org-ts-regexp-both nil t)) (org-follow-timestamp-link)) ((and (eq type 'clock) value (>= (point) (org-element-property :begin value)) (<= (point) (org-element-property :end value))) (org-follow-timestamp-link)) ((eq type 'src-block) (org-babel-open-src-block-result)) ((>= (point) (save-excursion (goto-char (org-element-property :end context)) (skip-chars-backward " \11") (point))) (user-error "No link found")) ((eq type 'inline-src-block) (org-babel-open-src-block-result)) ((eq type 'timestamp) (org-follow-timestamp-link)) ((eq type 'link) (org-link-open context arg)) (t (user-error "No link found")))
  (let* ((context (org-element-lineage (org-element-context) '(clock comment comment-block footnote-definition footnote-reference headline inline-src-block inlinetask keyword link node-property planning src-block timestamp) t)) (type (org-element-type context)) (value (org-element-property :value context))) (cond ((not type) (user-error "No link found")) ((memq type '(comment comment-block node-property keyword)) (call-interactively #'org-open-at-point-global)) ((memq type '(headline inlinetask)) (org-match-line org-complex-heading-regexp) (let ((tags-beg (match-beginning 5)) (tags-end (match-end 5))) (if (and tags-beg (>= (point) tags-beg) (< (point) tags-end)) (org-tags-view arg (save-excursion (let* ... ...))) (let* ((val ...)) (if (consp val) (let* ... ...) nil))))) ((or (eq type 'footnote-reference) (and (eq type 'footnote-definition) (save-excursion (skip-chars-forward " \11") (let (...) (if begin ... ...))))) (org-footnote-action)) ((and (eq type 'planning) (org-in-regexp org-ts-regexp-both nil t)) (org-follow-timestamp-link)) ((and (eq type 'clock) value (>= (point) (org-element-property :begin value)) (<= (point) (org-element-property :end value))) (org-follow-timestamp-link)) ((eq type 'src-block) (org-babel-open-src-block-result)) ((>= (point) (save-excursion (goto-char (org-element-property :end context)) (skip-chars-backward " \11") (point))) (user-error "No link found")) ((eq type 'inline-src-block) (org-babel-open-src-block-result)) ((eq type 'timestamp) (org-follow-timestamp-link)) ((eq type 'link) (org-link-open context arg)) (t (user-error "No link found"))))
  (if (run-hook-with-args-until-success 'org-open-at-point-functions) nil (let* ((context (org-element-lineage (org-element-context) '(clock comment comment-block footnote-definition footnote-reference headline inline-src-block inlinetask keyword link node-property planning src-block timestamp) t)) (type (org-element-type context)) (value (org-element-property :value context))) (cond ((not type) (user-error "No link found")) ((memq type '(comment comment-block node-property keyword)) (call-interactively #'org-open-at-point-global)) ((memq type '(headline inlinetask)) (org-match-line org-complex-heading-regexp) (let ((tags-beg (match-beginning 5)) (tags-end (match-end 5))) (if (and tags-beg (>= ... tags-beg) (< ... tags-end)) (org-tags-view arg (save-excursion ...)) (let* (...) (if ... ... nil))))) ((or (eq type 'footnote-reference) (and (eq type 'footnote-definition) (save-excursion (skip-chars-forward " \11") (let ... ...)))) (org-footnote-action)) ((and (eq type 'planning) (org-in-regexp org-ts-regexp-both nil t)) (org-follow-timestamp-link)) ((and (eq type 'clock) value (>= (point) (org-element-property :begin value)) (<= (point) (org-element-property :end value))) (org-follow-timestamp-link)) ((eq type 'src-block) (org-babel-open-src-block-result)) ((>= (point) (save-excursion (goto-char (org-element-property :end context)) (skip-chars-backward " \11") (point))) (user-error "No link found")) ((eq type 'inline-src-block) (org-babel-open-src-block-result)) ((eq type 'timestamp) (org-follow-timestamp-link)) ((eq type 'link) (org-link-open context arg)) (t (user-error "No link found")))))
  org-open-at-point(nil)
  funcall-interactively(org-open-at-point nil)
  call-interactively(org-open-at-point nil nil)
  command-execute(org-open-at-point)
#+end_example

I remember I saw some commit has diff on this change, but when I grepped on git log, I can't find them...

- -- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      
-----BEGIN PGP SIGNATURE-----

iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5Tb3AUHG51bWJjaGls
ZEBnbWFpbC5jb20ACgkQG13xyVromsN62Qf/UjunbVY8MFwQ8kdq+iitDNERskm9
hPNEEAH1uV0HKdg5n3UvIuySPntxPtzvQPQQdT0ADMun8sN4sbkEX3wKJ5wz8qkb
kd7ia3hpAW139mhaXqcbnhbibtM280nwRjbsomK4uEIN/mNmrnxjw/qqvj9cSlmk
Vo2ELa54lZcaA67oPQAiLrFWcgN9c1DQOx7Ip4sgEamLUmns1i0DF4k94QmvxKsQ
r5CAiEfw4BBmDZA91qzIPGLTZYfjxXhJITm3V8Z60n/Qug9bg4HBGAe62R96XoVr
+TdfFFGXin9dp1b61wtkvhCfsWHBeylukqBgcHnAocJIAPa6J4vOv0N0cQ==
=CBYb
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [BUG] Recently master branch commit breaks open file: link
  2020-02-24  6:38 [BUG] Recently master branch commit breaks open file: link stardiviner
@ 2020-02-24  8:41 ` Bastien
  2020-02-24 12:06   ` stardiviner
  0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2020-02-24  8:41 UTC (permalink / raw)
  To: stardiviner; +Cc: Org Mode

Hi Stardiviner,

stardiviner <numbchild@gmail.com> writes:

> When I open a link like this:

Thanks for testing links, the master branch contains a few changes.

> #+begin_src org
> [[file:~/Org/Tasks/Computer Todos.org::*TODO 厉害的人是怎么分析问题的?][厉害的人是怎么分析问题的?]]
> #+end_src
>
> I =[M-x toggle-debug-on-error]= got following stacktrace:
>
> #+begin_example
> Debugger entered--Lisp error: (file-missing "Reading directory" "No
> such file or directory"
> "/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My...")
>   access-file("/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My..." "Reading directory")

Is this directory* existing in your setup?

* /home/stardiviner/Org/Wiki/Thought/Data/Manuals/My...

If yes, do you know what causes Org to check for its existence?

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [BUG] Recently master branch commit breaks open file: link
  2020-02-24  8:41 ` Bastien
@ 2020-02-24 12:06   ` stardiviner
  2020-02-24 12:15     ` Bastien
  0 siblings, 1 reply; 11+ messages in thread
From: stardiviner @ 2020-02-24 12:06 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


Bastien <bzg@gnu.org> writes:

> Hi Stardiviner,
>
> stardiviner <numbchild@gmail.com> writes:
>
>> When I open a link like this:
>
> Thanks for testing links, the master branch contains a few changes.
>
>> #+begin_src org
>> [[file:~/Org/Tasks/Computer Todos.org::*TODO 厉害的人是怎么分析问题的?][厉害的人是怎么分析问题的?]]
>> #+end_src
>>
>> I =[M-x toggle-debug-on-error]= got following stacktrace:
>>
>> #+begin_example
>> Debugger entered--Lisp error: (file-missing "Reading directory" "No
>> such file or directory"
>> "/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My...")
>>   access-file("/home/stardiviner/Org/Wiki/Thought/Data/Manuals/My..." "Reading directory")
>
> Is this directory* existing in your setup?
>
> * /home/stardiviner/Org/Wiki/Thought/Data/Manuals/My...
>
> If yes, do you know what causes Org to check for its existence?

I confirm this link directory and file exists. Including the headline exists too.

So I did a git bisect. Found this bad commit caused this problem "afd3b04ec * bad ol: Extend open tooling in link parameters".

This commit introduced new open file link function.

>
> Thanks,


- -- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      
-----BEGIN PGP SIGNATURE-----

iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5TvDUUHG51bWJjaGls
ZEBnbWFpbC5jb20ACgkQG13xyVromsPWNAgAiGRD65HV+3j7jl+xxJgOuvRgy+O8
Os2BJkiKTrM8YYTX9icLnygAPQN9oXLOTYVXdShQWo1lHtpx0417bGBW+L7TglPW
hfdTYFl99No1+T0mnam0qnR44YDOrOYzPb83TqQnUOyhK/uWsk18pOhrvPf2UYpK
YxiIhGdlyosb41P+9gVzPfTM0akWHddNY/LZuJT+Irr84zpIAYwiXc24VXN6qhnB
/gDBosDGPbRl/XniFU3fUYSklHsBvUWuXb88df442pK+AfKEsh3c6lUqJ5AKtIm5
qmjye5OqZoQwt/zOpMakldvoK/hO/jT0UusRv1QqvKDpcyDAT7qrxIaODw==
=oJQL
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [BUG] Recently master branch commit breaks open file: link
  2020-02-24 12:06   ` stardiviner
@ 2020-02-24 12:15     ` Bastien
  2020-02-24 15:09       ` stardiviner
  0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2020-02-24 12:15 UTC (permalink / raw)
  To: stardiviner; +Cc: Org Mode

Hi Stardiviner,

stardiviner <numbchild@gmail.com> writes:

> So I did a git bisect. Found this bad commit caused this problem
> "afd3b04ec * bad ol: Extend open tooling in link parameters".

This will work:

#+begin_src org
[[file:~/Org/Tasks/Computer Todos.org::*厉害的人是怎么分析问题的?][厉害的人是怎么分析问题的?]]
#+end_src

org-store-link used to store the TODO keyword, which was a mistake.

Nicolas fixed this recently, now org-store-link DTRT and C-c C-o on
stored links will work correctly.

IMHO we may have several file links such as yours broken: Nicolas,
do you think the bugfix should be advertized in ORG-NEWS, along with
a helper function to fix file links (ie remove the TODO keyword and
priority cookies)?

-- 
 Bastien

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [BUG] Recently master branch commit breaks open file: link
  2020-02-24 12:15     ` Bastien
@ 2020-02-24 15:09       ` stardiviner
  2020-02-24 20:30         ` Bastien
  2020-02-24 20:35         ` Document backward-incompatible change in ORG-NEWS? (was: [BUG] Recently master branch commit breaks open file: link) Bastien
  0 siblings, 2 replies; 11+ messages in thread
From: stardiviner @ 2020-02-24 15:09 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


Bastien <bzg@gnu.org> writes:

> Hi Stardiviner,
>
> stardiviner <numbchild@gmail.com> writes:
>
>> So I did a git bisect. Found this bad commit caused this problem
>> "afd3b04ec * bad ol: Extend open tooling in link parameters".
>
> This will work:
>
> #+begin_src org
> [[file:~/Org/Tasks/Computer Todos.org::*厉害的人是怎么分析问题的?][厉害的人是怎么分析问题的?]]
> #+end_src
>
> org-store-link used to store the TODO keyword, which was a mistake.
>
> Nicolas fixed this recently, now org-store-link DTRT and C-c C-o on
> stored links will work correctly.

I see. Thanks for explanation.

>
> IMHO we may have several file links such as yours broken: Nicolas,
> do you think the bugfix should be advertized in ORG-NEWS, along with
> a helper function to fix file links (ie remove the TODO keyword and
> priority cookies)?

This broken update might need a little think.

The new org-store-link does not include the TODO keyword. But what if user add
keyword before, then later does not use it in Org Mode config. This TODO keyword
will caused broken.

I personally used to have an advice on org-store-link to auto prompt user a
"CUSTOM_ID" property with default value of headline string before (A month ago I
disabled it).

#+begin_src emacs-lisp
;;; use :CUSTOM_ID: property for org headlines linking.
(defun org-store-link-set-headline-custom-id (arg &optional interactive?)
  "Set property :CUSTOM_ID: for `org-store-link' on headline."
  (when (and (equal major-mode 'org-mode) ; handle case `org-store-link' not in org-mode file.
             (not (org-before-first-heading-p)) ; handle case point is in org-mode buffer ahead of first headline.
             ;; (org-on-heading-p t) ; detect whether on a headline
             ;; (re-search-backward (concat "^\\(?:" outline-regexp "\\)") nil t) ; detect whether under a headline?
             (not (region-active-p)) ; handle `org-drill' capture word case.
             (not (org-entry-get nil "CUSTOM_ID")))
    (if (yes-or-no-p "Set property :CUSTOM_ID: ? ")
        (org-set-property
         "CUSTOM_ID"
         (read-from-minibuffer "Property :CUSTOM_ID: value: "
                               (substring-no-properties (org-get-heading t t)))))))

(advice-add 'org-store-link :before #'org-store-link-set-headline-custom-id)
#+end_src

Is this solution will be better than headline link? Because it does not have to
consider TODO keyword, tags, end checkbox statistic etc. I know Org Mode has a
similar feature called ~org-id-link-to-org-use-id~. But I don't like meaningless
ID personally.

WDYT?

- -- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      
-----BEGIN PGP SIGNATURE-----

iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5T5xkUHG51bWJjaGls
ZEBnbWFpbC5jb20ACgkQG13xyVromsO2jgf+NXmuhKM7CyjoN0qq+DuKppTvkv5S
+iQUOOk5mGmRA8ayu6Veh1IJI5U/R61lXxYPJYzV6HIAuIG+Wz7c2UOUoJ4VJyf1
yp4sksY7d7/Uhak+hEjuQvsRWoT3F+80S251+kHcRkpyZZR41HLZVHlxLgGba6ub
DP+8X4EmxO3bOByK5ixAuGUPCqASfT+njSOFK7CUGDPlFt58dTb78Z/hj0b5/pv0
er0e0mS3m6matGAlsmb0A8GM+9I/TxqBGdc6SySUqNrVhGZFXMBt7090jllqb6Cq
SqGxUFUxI0G3vtZYp2kPPyaYCpb9OJlhKTVkd0PxCCWZrhuqKVyvx/OmNg==
=PJ1+
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [BUG] Recently master branch commit breaks open file: link
  2020-02-24 15:09       ` stardiviner
@ 2020-02-24 20:30         ` Bastien
  2020-02-24 20:35         ` Document backward-incompatible change in ORG-NEWS? (was: [BUG] Recently master branch commit breaks open file: link) Bastien
  1 sibling, 0 replies; 11+ messages in thread
From: Bastien @ 2020-02-24 20:30 UTC (permalink / raw)
  To: stardiviner; +Cc: Org Mode

Hi Stardiviner,

stardiviner <numbchild@gmail.com> writes:

>> IMHO we may have several file links such as yours broken: Nicolas,
>> do you think the bugfix should be advertized in ORG-NEWS, along with
>> a helper function to fix file links (ie remove the TODO keyword and
>> priority cookies)?
>
> This broken update might need a little think.
>
> The new org-store-link does not include the TODO keyword. But what if user add
> keyword before, then later does not use it in Org Mode config. This TODO keyword
> will caused broken.

You can run something like this command in your org files, it will
prompt you for the fixed link:

(defun org-fix-links ()
  "Fix ill-formatted internal links.
E.g. replace [[*TODO Headline][headline]] by [[*Headline][headline]].
Go through the buffer and ask for the replacement."
  (interactive)
  (visible-mode 1)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward org-link-any-re nil t)
      (let* ((raw (match-string 2))
	     (desc (match-string 3))
	     fix new)
	(when (and raw desc
		   (string-match-p
		    (concat "^\*" (regexp-opt org-todo-keywords-1)
			    "\\s-+\\(.+\\)$")
		    raw))
	  (setq new (replace-regexp-in-string
		     (concat (regexp-opt org-todo-keywords-1) "\\s-+")
		     "" raw))
	  (set-text-properties 0 (length new) nil new)
	  (setq fix (completing-read "Replace link at point by: "
				     nil nil nil new))
	  (replace-match (format "[[%s][%s]]" fix desc))))))
  (visible-mode -1))

HTH,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Document backward-incompatible change in ORG-NEWS? (was: [BUG] Recently master branch commit breaks open file: link)
  2020-02-24 15:09       ` stardiviner
  2020-02-24 20:30         ` Bastien
@ 2020-02-24 20:35         ` Bastien
  2020-02-24 21:31           ` Samuel Wales
  2020-02-25  9:10           ` Document backward-incompatible change in ORG-NEWS? Nicolas Goaziou
  1 sibling, 2 replies; 11+ messages in thread
From: Bastien @ 2020-02-24 20:35 UTC (permalink / raw)
  To: mail; +Cc: Org Mode

Hi Nicolas,

it seems that org-store-link stored links to headlines as

[[*TODO headline][headline]]

keeping the TODO keyword, if any.

This is fixed in master but I won't if we should document this bug
fix in ORG-NEWS (or if org-store-link was just momentarily broken.)

If org-store-link was storing the todo keyword, perhaps we can add
a command similar to this one to help users fix broken links:

(defun org-fix-links ()
  "Fix ill-formatted internal links.
E.g. replace [[*TODO Headline][headline]] by [[*Headline][headline]].
Go through the buffer and ask for the replacement."
  (interactive)
  (visible-mode 1)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward org-link-any-re nil t)
      (let* ((raw (match-string 2))
	     (desc (match-string 3))
	     fix new)
	(when (and raw desc
		   (string-match-p
		    (concat "^\*" (regexp-opt org-todo-keywords-1)
			    "\\s-+\\(.+\\)$")
		    raw))
	  (setq new (replace-regexp-in-string
		     (concat (regexp-opt org-todo-keywords-1) "\\s-+")
		     "" raw))
	  (set-text-properties 0 (length new) nil new)
	  (setq fix (completing-read "Replace link at point by: "
				     nil nil nil new))
	  (replace-match (format "[[%s][%s]]" fix desc))))))
  (visible-mode -1))

WDYT?

-- 
 Bastien

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Document backward-incompatible change in ORG-NEWS? (was: [BUG] Recently master branch commit breaks open file: link)
  2020-02-24 20:35         ` Document backward-incompatible change in ORG-NEWS? (was: [BUG] Recently master branch commit breaks open file: link) Bastien
@ 2020-02-24 21:31           ` Samuel Wales
  2020-02-25  7:02             ` stardiviner
  2020-02-25  9:10           ` Document backward-incompatible change in ORG-NEWS? Nicolas Goaziou
  1 sibling, 1 reply; 11+ messages in thread
From: Samuel Wales @ 2020-02-24 21:31 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode, mail

no opinion on anything but a suggestion.

i really like these little scripts that update your org files so they
are compatible with new org versions.

perhaps one can give them an argument or something to work on all
agenda files, or a list of files, or somethign liek that?

On 2/24/20, Bastien <bzg@gnu.org> wrote:
> Hi Nicolas,
>
> it seems that org-store-link stored links to headlines as
>
> [[*TODO headline][headline]]
>
> keeping the TODO keyword, if any.
>
> This is fixed in master but I won't if we should document this bug
> fix in ORG-NEWS (or if org-store-link was just momentarily broken.)
>
> If org-store-link was storing the todo keyword, perhaps we can add
> a command similar to this one to help users fix broken links:
>
> (defun org-fix-links ()
>   "Fix ill-formatted internal links.
> E.g. replace [[*TODO Headline][headline]] by [[*Headline][headline]].
> Go through the buffer and ask for the replacement."
>   (interactive)
>   (visible-mode 1)
>   (save-excursion
>     (goto-char (point-min))
>     (while (re-search-forward org-link-any-re nil t)
>       (let* ((raw (match-string 2))
> 	     (desc (match-string 3))
> 	     fix new)
> 	(when (and raw desc
> 		   (string-match-p
> 		    (concat "^\*" (regexp-opt org-todo-keywords-1)
> 			    "\\s-+\\(.+\\)$")
> 		    raw))
> 	  (setq new (replace-regexp-in-string
> 		     (concat (regexp-opt org-todo-keywords-1) "\\s-+")
> 		     "" raw))
> 	  (set-text-properties 0 (length new) nil new)
> 	  (setq fix (completing-read "Replace link at point by: "
> 				     nil nil nil new))
> 	  (replace-match (format "[[%s][%s]]" fix desc))))))
>   (visible-mode -1))
>
> WDYT?
>
> --
>  Bastien
>
>


-- 
The Kafka Pandemic

What is misopathy?
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Document backward-incompatible change in ORG-NEWS? (was: [BUG] Recently master branch commit breaks open file: link)
  2020-02-24 21:31           ` Samuel Wales
@ 2020-02-25  7:02             ` stardiviner
  0 siblings, 0 replies; 11+ messages in thread
From: stardiviner @ 2020-02-25  7:02 UTC (permalink / raw)
  To: Samuel Wales; +Cc: Bastien, emacs-orgmode, mail

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


Samuel Wales <samologist@gmail.com> writes:

> no opinion on anything but a suggestion.
>
> i really like these little scripts that update your org files so they
> are compatible with new org versions.
>
> perhaps one can give them an argument or something to work on all
> agenda files, or a list of files, or somethign liek that?

Sounds reasonable. Apply function on Org Agenda files will be the most case.

>
> On 2/24/20, Bastien <bzg@gnu.org> wrote:
>> Hi Nicolas,
>>
>> it seems that org-store-link stored links to headlines as
>>
>> [[*TODO headline][headline]]
>>
>> keeping the TODO keyword, if any.
>>
>> This is fixed in master but I won't if we should document this bug
>> fix in ORG-NEWS (or if org-store-link was just momentarily broken.)
>>
>> If org-store-link was storing the todo keyword, perhaps we can add
>> a command similar to this one to help users fix broken links:
>>
>> (defun org-fix-links ()
>>   "Fix ill-formatted internal links.
>> E.g. replace [[*TODO Headline][headline]] by [[*Headline][headline]].
>> Go through the buffer and ask for the replacement."
>>   (interactive)
>>   (visible-mode 1)
>>   (save-excursion
>>     (goto-char (point-min))
>>     (while (re-search-forward org-link-any-re nil t)
>>       (let* ((raw (match-string 2))
>> 	     (desc (match-string 3))
>> 	     fix new)
>> 	(when (and raw desc
>> 		   (string-match-p
>> 		    (concat "^\*" (regexp-opt org-todo-keywords-1)
>> 			    "\\s-+\\(.+\\)$")
>> 		    raw))
>> 	  (setq new (replace-regexp-in-string
>> 		     (concat (regexp-opt org-todo-keywords-1) "\\s-+")
>> 		     "" raw))
>> 	  (set-text-properties 0 (length new) nil new)
>> 	  (setq fix (completing-read "Replace link at point by: "
>> 				     nil nil nil new))
>> 	  (replace-match (format "[[%s][%s]]" fix desc))))))
>>   (visible-mode -1))
>>
>> WDYT?
>>
>> --
>>  Bastien
>>
>>


- -- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      
-----BEGIN PGP SIGNATURE-----

iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl5UxnwUHG51bWJjaGls
ZEBnbWFpbC5jb20ACgkQG13xyVromsPwpgf/RqdCj+Y5dC+3lRUwPwYsi8crTrYP
tOZdszU/V1mAPaEep8Q2ksJwvYBa/0TaZ7H+3M8rS55Ug9vSzQyZ/vO+MBSQIPu4
GcyWvyl6qxuWsn8YJr/2E5gGrvgCkGXbqf4tW4iSxm5gWT+Ui6wziW+c00++UFR9
40TnIVx5xx/2F3vuJGmXA9cyhm/K1O8rzG/7NUhvxypXZhFrU0Tns1WmeCUWi9/7
DPI+FRIxUBzcUlLhuZq3gHjDoCaIOie69MCFkrDFlHakr8s+rvbzokdff5C0r4vp
DCtdIgEAFUFQvcfD7v4b5+5YiYe6Aq2erX7Jrkhn1Pkguku11xNu17HeFQ==
=QjPn
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Document backward-incompatible change in ORG-NEWS?
  2020-02-24 20:35         ` Document backward-incompatible change in ORG-NEWS? (was: [BUG] Recently master branch commit breaks open file: link) Bastien
  2020-02-24 21:31           ` Samuel Wales
@ 2020-02-25  9:10           ` Nicolas Goaziou
  2020-02-25 19:34             ` Bastien
  1 sibling, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2020-02-25  9:10 UTC (permalink / raw)
  To: Bastien; +Cc: Org Mode

Hello,

Bastien <bzg@gnu.org> writes:

> This is fixed in master but I won't if we should document this bug
> fix in ORG-NEWS (or if org-store-link was just momentarily broken.)

You are right. This deserves an entry in ORG-NEWS.

> If org-store-link was storing the todo keyword, perhaps we can add
> a command similar to this one to help users fix broken links:
>
> (defun org-fix-links ()
>   "Fix ill-formatted internal links.
> E.g. replace [[*TODO Headline][headline]] by [[*Headline][headline]].
> Go through the buffer and ask for the replacement."
>   (interactive)
>   (visible-mode 1)
>   (save-excursion
>     (goto-char (point-min))
>     (while (re-search-forward org-link-any-re nil t)

I think this is inefficient. It would be better to search directly for

  (format "\\[\\[\\*%s\\s-+" (regexp-opt org-todo-keywords-1 t))

>       (let* ((raw (match-string 2))
> 	     (desc (match-string 3))
> 	     fix new)
> 	(when (and raw desc

Why does DESC matter here? We probably want to also replace

  [[*TODO foo]]

> 		   (string-match-p
> 		    (concat "^\*" (regexp-opt org-todo-keywords-1)

Typo: the correct regexp is "^\\*"

> 			    "\\s-+\\(.+\\)$")
> 		    raw))
> 	  (setq new (replace-regexp-in-string
> 		     (concat (regexp-opt org-todo-keywords-1) "\\s-+")
> 		     "" raw))
> 	  (set-text-properties 0 (length new) nil new)

Why do you remove all text properties? Also, see `org-no-properties'.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Document backward-incompatible change in ORG-NEWS?
  2020-02-25  9:10           ` Document backward-incompatible change in ORG-NEWS? Nicolas Goaziou
@ 2020-02-25 19:34             ` Bastien
  0 siblings, 0 replies; 11+ messages in thread
From: Bastien @ 2020-02-25 19:34 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode

Hi Nicolas,

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> You are right. This deserves an entry in ORG-NEWS.

thanks for your feedback, I've added this entry:
https://code.orgmode.org/bzg/org-mode/commit/1a84a8b611

> I think this is inefficient. It would be better to search directly for
>
>   (format "\\[\\[\\*%s\\s-+" (regexp-opt org-todo-keywords-1 t))

Indeed... I've pushed a simpler version, feel free to enhance it.

>> 	  (setq new (replace-regexp-in-string
>> 		     (concat (regexp-opt org-todo-keywords-1) "\\s-+")
>> 		     "" raw))
>> 	  (set-text-properties 0 (length new) nil new)
>
> Why do you remove all text properties? Also, see `org-no-properties'.

For the record, it seems that completing-read fifth argument cannot
be a string with properties - at least from the quick test I did.

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-02-25 19:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24  6:38 [BUG] Recently master branch commit breaks open file: link stardiviner
2020-02-24  8:41 ` Bastien
2020-02-24 12:06   ` stardiviner
2020-02-24 12:15     ` Bastien
2020-02-24 15:09       ` stardiviner
2020-02-24 20:30         ` Bastien
2020-02-24 20:35         ` Document backward-incompatible change in ORG-NEWS? (was: [BUG] Recently master branch commit breaks open file: link) Bastien
2020-02-24 21:31           ` Samuel Wales
2020-02-25  7:02             ` stardiviner
2020-02-25  9:10           ` Document backward-incompatible change in ORG-NEWS? Nicolas Goaziou
2020-02-25 19:34             ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).