From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id UGB9Ir9BxV5oEQAA0tVLHw (envelope-from ) for ; Wed, 20 May 2020 14:42:07 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id SJ9oHr9BxV4mVgAAB5/wlQ (envelope-from ) for ; Wed, 20 May 2020 14:42:07 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4ED5194038E for ; Wed, 20 May 2020 14:42:06 +0000 (UTC) Received: from localhost ([::1]:54026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbPv3-0002vI-2y for larch@yhetil.org; Wed, 20 May 2020 10:42:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbPuR-0002sn-7b for emacs-orgmode@gnu.org; Wed, 20 May 2020 10:41:27 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:39748) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jbPuP-00022O-3P for emacs-orgmode@gnu.org; Wed, 20 May 2020 10:41:26 -0400 Received: by mail-wm1-x331.google.com with SMTP id w64so3127484wmg.4 for ; Wed, 20 May 2020 07:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=andrew-cmu-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XLP9iChmKIFHoJO+js5FuOe9DzQwiIVuR7uo2WmVk04=; b=cu1Es6WFroVIIkB75f0tOZdaHHa7qfRTshTGj0ZvjsqusgQHdoxgnoDvpihP8GpMf6 5VNxnwLwOS4VbxditTpnJ9vivGYBek183b/pm+sFV9dDFPhE+zx7pdG8/GpPVj1OAhRj my8KeeNxhaRzDzQfpDoGrTnQThNBwFHYtvMsg01HwQM0cDJbx7hSnx7EAOAvzThZofiu Ut9n1NinXEE2Ag0DKDKdjCwt/Fto+a5bm0SekCvPEvunRRQSae1gkQNGuFi2UAt/EHpN 1PNaBa69JKEi9acsJHJRBrxw6R54dLVV3DwO5JbrOYrUliUWIGVzeD+/MRSR05OctOut 0TaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XLP9iChmKIFHoJO+js5FuOe9DzQwiIVuR7uo2WmVk04=; b=tBifH2cZcug3NdHZ18ZCxoiJrSLmoEIzsZs3PIanzWY0PhvpFrswXxwDpTBt3n3aKm 0cazSAoys+kvDpVAMwiKIVoAnPU6yunGdZ+uGNbTxr6Bwj7qYruhLmaSwgu+DpPvoJLe HUwqdahB7YfsFY37CTIKB48m1vwyFrJyt8qq/FKW4Dcu7ef2WRxxytdzOdGnwB2LnieH 58LY5QyMqwfurOnP5+jSBKCjOttAJ4TALTZBBAmwOjtt6mN+TbbopDTRU1cb65ggXi+T IwjbmSSISHb0xJvh/kva153LI5RPLPkyoei645bCghNSgCtt1ngZCmnwKsHas17W5tqd Gw4g== X-Gm-Message-State: AOAM530DRbehq8Nb+ux8rib+vu+uWrBwX7aDi0Sth8C0AbK/Axgesf6N btiuRkg46jJRUILzcN6xGZRw7sblHlzJ9h+jef0= X-Google-Smtp-Source: ABdhPJxdJqjN8Mwyc6dW7OVZpZl2xkizQMTle/yXzXC9ksS+/x4e+pGnGt4BmkRKUANbLvaFf3nMRKZyDBlthioLwbE= X-Received: by 2002:a1c:2348:: with SMTP id j69mr4997052wmj.11.1589985683048; Wed, 20 May 2020 07:41:23 -0700 (PDT) MIME-Version: 1.0 References: <87wo58jch2.fsf@gmail.com> <87lflnczdy.fsf@gmail.com> In-Reply-To: <87lflnczdy.fsf@gmail.com> From: John Kitchin Date: Wed, 20 May 2020 10:41:12 -0400 Message-ID: Subject: Re: [Question] why my org-link-set-parameters :face function does not work? To: numbchild@gmail.com Content-Type: multipart/alternative; boundary="000000000000d60ef205a6156355" Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=johnrkitchin@gmail.com; helo=mail-wm1-x331.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org Mode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=andrew-cmu-edu.20150623.gappssmtp.com header.s=20150623 header.b=cu1Es6WF; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=andrew.cmu.edu (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.11 X-TUID: YLXOB7kd9hFH --000000000000d60ef205a6156355 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 cann= ot > > 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=E2=80=99t work with org-link-set-parameters because the face funct= ion 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 =3DC-u C-M-x=3D 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=E2=80=99t think you can use edebug in font lock functions. I always u= se the old fashioned (message =E2=80=9C%s=E2=80=9D thing-i-want-to-see) approach. Maybe there is some fancy way to do it, e.g. font-lock-studio, but I don=E2= =80=99t 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 expres= s. > >> > >> 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=3D=3D > >> =3D4fE9 > >> -----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=3D=3D > =3DOU9d > -----END PGP SIGNATURE----- > > -- 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 --000000000000d60ef205a6156355 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, May 19, 2020 at 6:51 PM stardiviner <numbchild@gmail.com> wrote:
-----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 can= not
> use org-element-property on it.
>
> Maybe you want something like this:
>
> #+begin_src emacs-lisp
> (defun org-link-beautify-face (path)
>=C2=A0 =C2=A0"Set link face colors."
>=C2=A0 =C2=A0(message "beautifying")
>=C2=A0 =C2=A0(if (and (not (file-remote-p path))
>=C2=A0 =C2=A0(file-exists-p (expand-file-name path)))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0'org-link
>=C2=A0 =C2=A0 =C2=A0'org-warning))
>
> ;;; DEBUG
> (org-link-set-parameters
>=C2=A0 "file"
>=C2=A0 :face #'org-link-beautify-face)
> #+end_src

I actually borrowed code from your code example, Because I want to do the f= ollowing:

Where did you fi= nd code that uses org-element-property on a link like this? This won=E2=80= =99t work with org-link-set-parameters because the face function does not g= et an org-element, it gets only the path part of it.


#+begin_src emacs-lisp
(defun org-link-beautify-face (link)
=C2=A0 "Set link face colors."
=C2=A0 (let ((raw-link (org-element-property :raw-link link))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (type (org-element-property :type link))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (path (org-element-property :path link)))
=C2=A0 =C2=A0 (pcase type
=C2=A0 =C2=A0 =C2=A0 ;; ("https" )
=C2=A0 =C2=A0 =C2=A0 ;; ("http" )
=C2=A0 =C2=A0 =C2=A0 ("file"
=C2=A0 =C2=A0 =C2=A0 =C2=A0(if (and (not (file-remote-p path))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (file-exists-p (exp= and-file-name path)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'org-link 'org-warning))))= )

(dolist (link-type (mapcar 'car org-link-parameters))
=C2=A0 (org-link-set-parameters link-type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0: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 =3DC-u C-M-x=3D set edebug on the = function, and
toggle ~font-lock-mode~ on Org Mode buffer, this function is not entering e= debug.
Don't know how to make Emacs enter this function edebug status.

I don=E2=80=99t = think you can use edebug in font lock functions. I always use the old fashi= oned (message =E2=80=9C%s=E2=80=9D thing-i-want-to-see) approach.

Maybe there is some fancy way to = do it, e.g. font-lock-studio, but I don=E2=80=99t 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 <numbchild@gmail.com> wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>>
>> Bellowing is my source code, it does not work. I'm wondering w= hy?
>>
>> #+begin_src emacs-lisp
>> (defun org-link-beautify-face (link)
>>=C2=A0 =C2=A0"Set link face colors."
>>=C2=A0 =C2=A0(let ((raw-link (org-element-property :raw-link link))=
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(type (org-element-property :type= link))
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(path (org-element-property :path= link)))
>>=C2=A0 =C2=A0 =C2=A0(pcase type
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0;; ("https" )
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0;; ("http" )
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0("file"
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 (if (and (not (file-remote-p path))
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(file= -exists-p (expand-file-name path)))
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 'org-link 'org-wa= rning)))))
>>
>> ;;; DEBUG
>> (org-link-set-parameters
>>=C2=A0 "file"
>>=C2=A0 :face #'org-link-beautify-face)
>> #+end_src
>>
>> - --
>> [ stardiviner ]
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 I try to make every word tell the meani= ng that I want to express.
>>
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 Blog: https://stardiviner.github.i= o/
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 IRC(freenode): stardiviner, Matrix: sta= rdiviner
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 GPG: F09F650D7D674819892591401B5DF1C95A= E89AC3
>>
>> -----BEGIN PGP SIGNATURE-----
>>
>> iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7D2xkUHG51bWJjaGls >> ZEBnbWFpbC5jb20ACgkQG13xyVromsMfHAgAjnoQlzdHlcKL/rBVBLlkmMITh7f5 >> 6SxRw9sS1BagIma+APiuy+A4O4fSDLyzUMDg+Sg/C+vNu3QC2BM7ipBYNXtWcX1M >> oPZj8loMrnISTIK51j2+9Pg0iOP1aZSvZqwA0p1mK2aZURBXWl7qDkVxD2oWji5P >> qCBVr9ZFUloGSl7PtZTlOtsCgTCGHvnfvnk7vqxY4beuavQgaRSWUCsVDDO0c/M6 >> 5CSzxobElB3Y68fQ2awuQwRGCzfEvRkGShHp3Raug+EJ5Ew+MYEi6wILfPxYF2WR >> VJjuxAxseBuiIjYjF91xzbR7mSZQsvB1gNttLYb3uQ/jrgj0HOQDo5Jmtg=3D=3D >> =3D4fE9
>> -----END PGP SIGNATURE-----
>>
>>


- --
[ stardiviner ]
=C2=A0 =C2=A0 =C2=A0 =C2=A0I try to make every word tell the meaning that I= want to express.

=C2=A0 =C2=A0 =C2=A0 =C2=A0Blog: https://stardiviner.github.io/ =C2=A0 =C2=A0 =C2=A0 =C2=A0IRC(freenode): stardiviner, Matrix: stardiviner<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
-----BEGIN PGP SIGNATURE-----

iQFIBAEBCAAyFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAl7EYtkUHG51bWJjaGls
ZEBnbWFpbC5jb20ACgkQG13xyVromsOnbwf/f5zAf2fh+vUg7ikwtXpzCL+cjeUt
vyyHH9R32K5nb0FTqeyL/rjw6AhHRsTR7sFSUkb++Q8uWRJyxT2Kt7bgujRsL/cb
bnmArq4HFWw7ysxYjhDSknwzhc4xFzUJpSmnZuNHEItIuV5Ghg/FnEJokcTurop2
jN4dw28ladHMLel2hjhIRQni3ugQwfKOuyBZa8U3SCPENfnK8uPbMoxkONgdmDQu
wG3qw8NvMFnD5Vr81qVb/ytGJyMv+34wD/unZ1TK7BaTGsOVvg/l8ssj5h3EsDeX
yilYhc2yZmbG9DHiL94L7ggXJFnVD9GY01xreZXz+JLyJdVQy3K+Rmow1w=3D=3D
=3DOU9d
-----END PGP SIGNATURE-----

--
J= ohn

-----------------------------------
Professor John Kitchin=C2= =A0
Doherty Hall A207F
Department of Chemical Engineering
Carnegie= Mellon University
Pittsburgh, PA 15213
412-268-7803
=
--000000000000d60ef205a6156355--