From: stardiviner <numbchild@gmail.com>
To: John Kitchin <jkitchin@andrew.cmu.edu>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [Question] why my org-link-set-parameters :face function does not work?
Date: Wed, 20 May 2020 06:51:05 +0800 [thread overview]
Message-ID: <87lflnczdy.fsf@gmail.com> (raw)
In-Reply-To: <CAJ51ETpJGLD0hRCy53m-n=tgsGj-HXHeZNsqC9y=+fxYOWGfhA@mail.gmail.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> The face function only takes the link path, which is a string. you cannot
> use org-element-property on it.
>
> Maybe you want something like this:
>
> #+begin_src emacs-lisp
> (defun org-link-beautify-face (path)
> "Set link face colors."
> (message "beautifying")
> (if (and (not (file-remote-p path))
> (file-exists-p (expand-file-name path)))
> 'org-link
> 'org-warning))
>
> ;;; DEBUG
> (org-link-set-parameters
> "file"
> :face #'org-link-beautify-face)
> #+end_src
I actually borrowed code from your code example, Because I want to do the following:
#+begin_src emacs-lisp
(defun org-link-beautify-face (link)
"Set link face colors."
(let ((raw-link (org-element-property :raw-link link))
(type (org-element-property :type link))
(path (org-element-property :path link)))
(pcase type
;; ("https" )
;; ("http" )
("file"
(if (and (not (file-remote-p path))
(file-exists-p (expand-file-name path)))
'org-link 'org-warning)))))
(dolist (link-type (mapcar 'car org-link-parameters))
(org-link-set-parameters link-type
:face #'org-link-beautify-face))
#+end_src
In this way, I can put my code in a union function.
I guess the issue is on the let-binding which invoked ~org-element-property~. But
I can't edebug this function. When I =C-u C-M-x= set edebug on the function, and
toggle ~font-lock-mode~ on Org Mode buffer, this function is not entering edebug.
Don't know how to make Emacs enter this function edebug status.
>
> John
>
> -----------------------------------
> Professor John Kitchin
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
>
>
> On Tue, May 19, 2020 at 9:12 AM stardiviner <numbchild@gmail.com> wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>>
>> Bellowing is my source code, it does not work. I'm wondering why?
>>
>> #+begin_src emacs-lisp
>> (defun org-link-beautify-face (link)
>> "Set link face colors."
>> (let ((raw-link (org-element-property :raw-link link))
>> (type (org-element-property :type link))
>> (path (org-element-property :path link)))
>> (pcase type
>> ;; ("https" )
>> ;; ("http" )
>> ("file"
>> (if (and (not (file-remote-p path))
>> (file-exists-p (expand-file-name path)))
>> 'org-link 'org-warning)))))
>>
>> ;;; DEBUG
>> (org-link-set-parameters
>> "file"
>> :face #'org-link-beautify-face)
>> #+end_src
>>
>> - --
>> [ stardiviner ]
>> I try to make every word tell the meaning that I want to express.
>>
>> Blog: https://stardiviner.github.io/
>> IRC(freenode): stardiviner, Matrix: stardiviner
>> GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>>
>> -----BEGIN PGP SIGNATURE-----
>>
>> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7D2xkUHG51bWJjaGls
>> ZEBnbWFpbC5jb20ACgkQG13xyVromsMfHAgAjnoQlzdHlcKL/rBVBLlkmMITh7f5
>> 6SxRw9sS1BagIma+APiuy+A4O4fSDLyzUMDg+Sg/C+vNu3QC2BM7ipBYNXtWcX1M
>> oPZj8loMrnISTIK51j2+9Pg0iOP1aZSvZqwA0p1mK2aZURBXWl7qDkVxD2oWji5P
>> qCBVr9ZFUloGSl7PtZTlOtsCgTCGHvnfvnk7vqxY4beuavQgaRSWUCsVDDO0c/M6
>> 5CSzxobElB3Y68fQ2awuQwRGCzfEvRkGShHp3Raug+EJ5Ew+MYEi6wILfPxYF2WR
>> VJjuxAxseBuiIjYjF91xzbR7mSZQsvB1gNttLYb3uQ/jrgj0HOQDo5Jmtg==
>> =4fE9
>> -----END PGP SIGNATURE-----
>>
>>
- --
[ stardiviner ]
I try to make every word tell the meaning that I want to express.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
-----BEGIN PGP SIGNATURE-----
iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7EYtkUHG51bWJjaGls
ZEBnbWFpbC5jb20ACgkQG13xyVromsOnbwf/f5zAf2fh+vUg7ikwtXpzCL+cjeUt
vyyHH9R32K5nb0FTqeyL/rjw6AhHRsTR7sFSUkb++Q8uWRJyxT2Kt7bgujRsL/cb
bnmArq4HFWw7ysxYjhDSknwzhc4xFzUJpSmnZuNHEItIuV5Ghg/FnEJokcTurop2
jN4dw28ladHMLel2hjhIRQni3ugQwfKOuyBZa8U3SCPENfnK8uPbMoxkONgdmDQu
wG3qw8NvMFnD5Vr81qVb/ytGJyMv+34wD/unZ1TK7BaTGsOVvg/l8ssj5h3EsDeX
yilYhc2yZmbG9DHiL94L7ggXJFnVD9GY01xreZXz+JLyJdVQy3K+Rmow1w==
=OU9d
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2020-05-19 22:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 13:11 [Question] why my org-link-set-parameters :face function does not work? stardiviner
2020-05-19 13:23 ` John Kitchin
2020-05-19 22:51 ` stardiviner [this message]
2020-05-20 14:41 ` John Kitchin
2020-05-20 22:47 ` stardiviner
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
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=87lflnczdy.fsf@gmail.com \
--to=numbchild@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=jkitchin@andrew.cmu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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
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).