Re: [Question] why my org-link-set-parameters :face function does not work?

2020-05-20 Thread stardiviner
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256


John Kitchin  writes:

> On Tue, May 19, 2020 at 6:51 PM stardiviner  wrote:
>
>> I actually borrowed code from your code example, Because I want to do the
>> following:
>>
>
> Where did you find code that uses org-element-property on a link like this?
> This won’t work with org-link-set-parameters because the face function does
> not get an org-element, it gets only the path part of it.
>

Aha, I see. Thanks for point this out. I have not realized Org only pass the
path instead of whole link. I will take a note of this in my notebook.

>> 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.
>>
>
> I don’t think you can use edebug in font lock functions. I always use the
> old fashioned (message “%s” thing-i-want-to-see) approach.
>
> Maybe there is some fancy way to do it, e.g. font-lock-studio, but I don’t
> do it often enough to be fluent in fancy things!
>

Seems this is the way to debug it. Thanks again. :)

- -- 
[ 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-

iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7Fs28UHG51bWJjaGls
ZEBnbWFpbC5jb20ACgkQG13xyVromsM9Uwf/UIxjUkz5aVau8SJEp0DgonNxyYab
lEWns2iyz4F89rY3i0CMjt3T7HR7VMdgEHLZFtDwvQPda6vqD/4wLzQdWikirXjA
F7hl+CWop0lQW2VPPswatFuHyJd/WOsqR541bnv6Mwlk0/rO/OrRV6FOzoDqCeEW
2IsjZufigeNpn7xxiuU0T8JmvGQF1TLl3aYdEzDaq/RZleFVwoy1lFwEir4aENj1
FTumDx39STgIQujtuQa8QdiBg6F88RS5m1yAoVZY0EXYWnGXl8OFAfRYb8gLvGV9
v5eCdELIeSPc2ADWEb4Snm2C4uuk7CBkBWJzpdtZ/5ylgTZL8O/pwbdRsg==
=fzCV
-END PGP SIGNATURE-



Re: [Question] why my org-link-set-parameters :face function does not work?

2020-05-20 Thread John Kitchin
On Tue, May 19, 2020 at 6:51 PM stardiviner  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
>
> John Kitchin  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:
>

Where did you find code that uses org-element-property on a link like this?
This won’t work with org-link-set-parameters because the face function does
not get an org-element, it gets only the path part of it.


> #+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.
>

I don’t think you can use edebug in font lock functions. I always use the
old fashioned (message “%s” thing-i-want-to-see) approach.

Maybe there is some fancy way to do it, e.g. font-lock-studio, but I don’t
do it often enough to be fluent in fancy things!


> >
> > 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  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
> yilYhc2yZmbG9DHiL94L7ggXJFnVD9GY01xreZX

Re: [Question] why my org-link-set-parameters :face function does not work?

2020-05-19 Thread stardiviner
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256


John Kitchin  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  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-



Re: [Question] why my org-link-set-parameters :face function does not work?

2020-05-19 Thread John Kitchin
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

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


[Question] why my org-link-set-parameters :face function does not work?

2020-05-19 Thread stardiviner
-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-