help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get the actual face attribute?


From: Yuan Fu
Subject: Re: How to get the actual face attribute?
Date: Wed, 24 Jun 2020 00:12:22 -0400


> On Jun 22, 2020, at 5:27 PM, Emanuel Berg via Users list for the GNU Emacs 
> text editor <help-gnu-emacs@gnu.org> wrote:
> 
> Yuan Fu wrote:
> 
>> (let* ((p (or point (point))))
>>    (if (eq (char-after point) ?\t)
>>        (valign--tab-width (font-at p))
>>      ;; (font-at 0 nil (buffer-substring p (1+ p))) doesn’t work, the
>>      ;; font is sometimes wrong.  (font-at p) doesn’t work, because
>>      ;; it requires the buffer to be visible.
>>      (aref (aref (font-get-glyphs (font-at p) p (1+ p)) 0) 4)))
> 
> Hello Yuan Fu, you have a cool name :)
> 
> re: code, the byte compiler is always your friend:
> 
>    geh.el: 
>    In do-something:
>    geh.el:10:17:Warning: reference to free variable ‘point’
> 
>    In end of data:
>    geh.el:110:1:Warning: the function ‘valign--tab-width’ is not known to be
>        defined.
> 
> Also style point #1:
> 
>  (aref (aref (font-get-glyphs (font-at p) p (1+ p)) 0) 4)))
> 
> Suggestion, break it up, do more `let*'.
> 
> ditto #2:
> 
>  (or point (point))
> 
> Straight long-ear [1] use of `or' :) However the
> particular
> 
>  point (point) 
> 
> is confusing IMO.
> 

It’s used to support optional argument POINT.

> ditto #3:
> 
>  ... 0) 4)))
> 
> hard-coded data can also be put into `let*' to
> increase clarity, however if they only appear once
> one is allowed... heh :) one is allowed to have them
> hard-coded. if they ever appear twice names,
> variables/bindings are compulsory, with the possible
> exceptions of -1, 0, 1, nil and t :)

Ok, I’ll use more let next time. Thanks!

Yuan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]