[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
backquote upon variable for :eval
From: |
Christopher Dimech |
Subject: |
backquote upon variable for :eval |
Date: |
Sun, 28 Jul 2024 23:04:40 +0200 |
> Sent: Monday, July 29, 2024 at 8:44 AM
> From: "Heime" <heimeborgia@protonmail.com>
> To: "Manuel Giraud" <manuel@ledu-giraud.fr>
> Cc: "Heime via Users list for the GNU Emacs text editor"
> <help-gnu-emacs@gnu.org>
> Subject: Re: backquote upon variable for :eval
>
>
>
>
>
>
> Sent with Proton Mail secure email.
>
> On Monday, July 29th, 2024 at 8:24 AM, Manuel Giraud via Users list for the
> GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> > Heime heimeborgia@protonmail.com writes:
> >
> > > I am using the backquote, but I get errors when using ,tknm
> > >
> > > How can this be fixed ? Perhaps I got to arrange the code in a
> > > different way ?
> >
> >
> > Yes I think that you should re-arrange and re-read "(elisp) Backquote"
> > and maybe "(elisp) Evaluation" too.
> >
> > [...]
> >
> > > (defun vodil-bfnap (wmax &optional actn)
> > >
> > > (setq-default mode-line-buffer-identification
> > > `(:eval
> > > (let* ( (bfnm (buffer-name (window-buffer)))
> > > (tknm (if (> (length bfnm) wmax)
> > > (vodil-ellipses bfnm wmax actn)
> > > bfnm)) )
> > > (propertized-buffer-identification (format " %s " ,tknm))))))
> >
> >
> > What could contain an evaluation of tknm here?
> > --
> > Manuel Giraud
>
> Have done this, but although it works, the buffer name is always *scratch*
>
> (defun vodil-bfnap (wmax &optional actm)
>
> (let* ( (bfnm (buffer-name (window-buffer)))
> (tknm (if (> (length bfnm) wmax)
> (vodil-ellipses bfnm wmax actm)
> bfnm)))
> (setq-default mode-line-buffer-identification
> `(:eval (propertized-buffer-identification (format " %s " ,tknm))))))
In your function, the values of wmax and actm need to be evaluated because they
are
external variables passed as arguments. The other variables (bfnm and tknm)
are local
to the let* block and do not require special handling with the backquote-comma
syntax
for evaluation.
(defun vodil-bfnap (wmax &optional actn)
(setq-default mode-line-buffer-identification
`(:eval
(let* ( (bfnm (buffer-name (window-buffer)))
(tknm (if (> (length bfnm) ,wmax)
(vodil-ellipses bfnm ,wmax ,actn)
bfnm)) )
(propertized-buffer-identification (format " %s " tknm))))))