all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* backquote upon variable for :eval
@ 2024-07-28 20:10 Heime
  2024-07-28 20:24 ` Manuel Giraud via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 4+ messages in thread
From: Heime @ 2024-07-28 20:10 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

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 ?


(defun vodil-ellipses (bfname wmax &optional actn)
  (if (equal actn 'concat)
      (concat (substring bfname 0 (- wmax 1)) "… ")
    (truncate-string-to-width bfname wmax nil nil "…")) )


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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: backquote upon variable for :eval
  2024-07-28 20:10 backquote upon variable for :eval Heime
@ 2024-07-28 20:24 ` Manuel Giraud via Users list for the GNU Emacs text editor
  2024-07-28 20:44   ` Heime
  0 siblings, 1 reply; 4+ messages in thread
From: Manuel Giraud via Users list for the GNU Emacs text editor @ 2024-07-28 20:24 UTC (permalink / raw)
  To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: backquote upon variable for :eval
  2024-07-28 20:24 ` Manuel Giraud via Users list for the GNU Emacs text editor
@ 2024-07-28 20:44   ` Heime
  2024-07-28 21:04     ` Christopher Dimech
  0 siblings, 1 reply; 4+ messages in thread
From: Heime @ 2024-07-28 20:44 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Heime via Users list for the GNU Emacs text editor






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






^ permalink raw reply	[flat|nested] 4+ messages in thread

* backquote upon variable for :eval
  2024-07-28 20:44   ` Heime
@ 2024-07-28 21:04     ` Christopher Dimech
  0 siblings, 0 replies; 4+ messages in thread
From: Christopher Dimech @ 2024-07-28 21:04 UTC (permalink / raw)
  To: Heime; +Cc: Manuel Giraud, Heime via Users list for the GNU Emacs text editor


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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-28 21:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-28 20:10 backquote upon variable for :eval Heime
2024-07-28 20:24 ` Manuel Giraud via Users list for the GNU Emacs text editor
2024-07-28 20:44   ` Heime
2024-07-28 21:04     ` Christopher Dimech

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.