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: Emanuel Berg
Subject: Re: How to get the actual face attribute?
Date: Mon, 22 Jun 2020 23:27:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

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.

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

Keep 'em coming...


[1] https://en.wikipedia.org/wiki/Hanau_epe

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

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