GNU bug report logs - #70036
30.0.50; Move file-truename to the C level

Previous Next

Package: emacs;

Reported by: Theodor Thornhill <theo <at> thornhill.no>

Date: Wed, 27 Mar 2024 19:10:02 UTC

Severity: normal

Found in version 30.0.50

Full log


View this message in rfc822 format

From: Theodor Thornhill <theo <at> thornhill.no>
To: João Távora <joaotavora <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 70036 <at> debbugs.gnu.org, felician.nemeth <at> gmail.com
Subject: bug#70036: a fix that
Date: Fri, 19 Apr 2024 13:51:12 +0200
Theodor Thornhill <theo <at> thornhill.no> writes:

> João Távora <joaotavora <at> gmail.com> writes:
>
>> On Fri, Apr 19, 2024 at 12:32 PM Theodor Thornhill <theo <at> thornhill.no> wrote:
>>
>>> I wonder - why can't we use just buffer-file-truename?
>>>
>>> In the below function, wouldn't buffer-file-truename let us avoid the
>>> file-truename in eglot-path-to-uri?
>>
>> Never used, but try it out.  It seems it's already a built-in cache
>> of whatever the buffer's truename is (and the docstring says
>> it does call the slow `file-truename`).  But like in my patch, it's
>> a one-time thing.  So yeah, if it's available in old Emacsen as well,
>>  it could replace `eglot--cached-tdi`, but then the search in the
>> publishDiagnostics
>> handler would have to be adjusted accordingly to call uri-to-path again.
>
> What would you consider as a sufficiently old Emacs?
>

I guess this should be enough:

commit f6ed2e848d23035748b621a86be74956c093823f
Author: Richard M. Stallman <rms <at> gnu.org>
Date:   Tue Feb 14 16:33:19 1995 +0000

    (syms_of_buffer): Set up Lisp var buffer-file-truename.
    (init_buffer_once): Set up flag and default value for file_truename.
    (reset_buffer): Init file_truename slot.

diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3011,0 +3014,5 @@
+  DEFVAR_PER_BUFFER ("buffer-file-truename", &current_buffer->file_truename,
+		     make_number (Lisp_String),
+    "Truename of file visited in current buffer, or nil if not visiting a file.\n\
+The truename of a file is calculated by `file-truename'.\n\
+Each buffer has its own value of this variable.");

Theo




This bug report was last modified 1 year and 104 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.