all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 54459@debbugs.gnu.org
Subject: bug#54459: 29.0.50; Simplify connection-local variables (feature request)
Date: Sat, 19 Mar 2022 04:41:52 +0100	[thread overview]
Message-ID: <87bky2zjzz.fsf@aol.com> (raw)
In-Reply-To: 87bky2zjzz.fsf.ref@aol.com



Hi:

I use tramp very often and I find myself using this sort of snippet very
often:

(defvar-local gtags--executable 'unknown)

(defun gtags--executable ()
  (cond
   ((not (eq gtags--executable 'unknown)) ;; the value is already cached
    gtags--executable)
   ((file-remote-p default-directory)
    (with-connection-local-variables
     (if (boundp 'gtags--executable-connection)
         (setq-local gtags--executable gtags--executable-connection)

       ;; Else search and set as connection local for next uses.
       (setq-local gtags--executable (executable-find "gtags" t))
       (let* ((host (file-remote-p default-directory 'host))
              (symvars (intern (concat host "-gtags--vars")))) ;; profile name

         (connection-local-set-profile-variables
          symvars
          `((gtags--executable-connection . ,gtags--executable)))
         (connection-local-set-profiles `(:machine ,host) symvars))

       gtags--executable)))
   (t     ;; use default value (searched locally)
    (setq gtags--executable gtags-executable))))

The idea is that when using tramp with company it doesn't call
executable-find constantly in the remote buffers.

There are 3 issues that could be solved/improved:

1) If another buffer of a file in the same remote host is already open,
then when the function is called in that buffer for the first time it
will use the value cached in gtags--executable-connection. That's why in
the code I need to create a buffer local variable... Could we provide a
way to update all of them immediately?

2) There are functions to set connection-local profile variables
(connection-local-set-profile-variables) But so far there are not any
clean way to append variables to an existing profile; so a call to
connection-local-set-profile-variables deleted any previous variable,
actually the user is enforced to create a unique name for every profile
every time it needs something like this.

3) In the ideal world it may be possible to add an optional parameter to
tell executable-find to cache the found values per host and executable
name... so it could avoid the extra remote search... I understand this
shouldn't be enabled by default, but many packages may find it
useful. executable-find could be smart enough to remember some of the
previous searches at least in remote hosts.

Does it makes sense?



In GNU Emacs 29.0.50 (build 133, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.4)
 of 2022-03-18 built on Ergus
Repository revision: 9bcf58d27c7c9ebe3bdd4d0564808767420bd44c
Repository branch: feature/completions-customs
System Description: Arch Linux

Configured using:
 'configure --prefix=/home/ergo/.local/ --with-mailutils --with-json
 --with-x-toolkit=gtk3 --with-xft --with-wide-int --with-modules
 --with-cairo --with-harfbuzz --with-native-compilation --with-pgtk'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER
PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
WEBP XIM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
  shell-dirtrack-mode: t
  recentf-mode: t
  windmove-mode: t
  global-auto-revert-mode: t
  xclip-mode: t
  electric-pair-mode: t
  flyspell-mode: t
  company-mode: t
  flycheck-mode: t
  diff-hl-margin-local-mode: t
  diff-hl-margin-mode: t
  diff-hl-mode: t
  vertico-mouse-mode: t
  vertico-mode: t
  composable-mark-mode: t
  composable-mode: t
  repeat-mode: t
  xterm-mouse-mode: t
  my/consult-mode: t
  minibuffer-depth-indicate-mode: t
  winner-mode: t
  save-place-mode: t
  delete-selection-mode: t
  savehist-mode: t
  global-display-fill-column-indicator-mode: t
  display-fill-column-indicator-mode: t
  global-display-line-numbers-mode: t
  display-line-numbers-mode: t
  which-key-mode: t
  override-global-mode: t
  eldoc-mode: t
  show-paren-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
~/gits/emacs_clones/composable/composable-mark hides /home/ergo/.config/emacs/elpa/composable-20201024.1458/composable-mark
~/gits/emacs_clones/composable/composable hides /home/ergo/.config/emacs/elpa/composable-20201024.1458/composable
/home/ergo/.config/emacs/elpa/transient-20220314.1605/transient hides /home/ergo/.local/share/emacs/29.0.50/lisp/transient

Features:
(shadow sort mail-extr emacsbug message yank-media rmc puny rfc822 mml
mml-sec epa derived epg rfc6068 epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils tramp-cmds
move-dup dabbrev tramp-cache tramp-sh tramp tramp-loaddefs trampver
tramp-integration cus-edit cus-start cus-load files-x tramp-compat shell
pcomplete parse-time iso8601 time-date ls-lisp format-spec consult-xref
consult-vertico consult recentf tree-widget wid-edit bookmark windmove
shortdoc edebug comp comp-cstr warnings backtrace vertico-directory
slime compile text-property-search etags fileloop generator xref project
arc-mode archive-mode noutline outline pp comint hyperspec browse-url
url url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap vertico-repeat help-fns radix-tree misearch
multi-isearch autorevert filenotify ffap thingatpt url-parse auth-source
password-cache url-vars xclip yasnippet elec-pair flyspell-correct
flyspell ispell company-semantic company-template company-capf
company-elisp company flycheck ansi-color json map find-func dash pcase
diff-hl-margin diff-hl-dired advice dired-x dired dired-loaddefs diff-hl
log-view pcvs-util vc-dir ewoc vc orderless vertico-mouse vertico cape
vc-git diff-mode vc-dispatcher term/tmux term/xterm xterm init
composable composable-mark repeat xt-mouse simple-16-theme edmacro
kmacro mb-depth winner ring saveplace delsel savehist
display-fill-column-indicator display-line-numbers diminish which-key
cl-extra help-mode use-package use-package-ensure use-package-delight
use-package-diminish use-package-bind-key bind-key easy-mmode
use-package-core disp-table info ede/auto eieio-base cl-seq eieio seq
subr-x byte-opt bytecomp byte-compile cconv eieio-core cl-macs gv
eieio-loaddefs cl-loaddefs cl-lib tex-site rx slime-autoloads early-init
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget keymap hashtable-print-readable backquote threads
dbusbind inotify dynamic-setting system-font-setting font-render-setting
cairo gtk pgtk lcms2 multi-tty make-network-process native-compile
emacs)

Memory information:
((conses 16 360454 37148)
 (symbols 48 25759 0)
 (strings 32 93741 6885)
 (string-bytes 1 3439933)
 (vectors 16 43509)
 (vector-slots 8 1146293 11857)
 (floats 8 191 1739)
 (intervals 56 7499 470)
 (buffers 992 17))





       reply	other threads:[~2022-03-19  3:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87bky2zjzz.fsf.ref@aol.com>
2022-03-19  3:41 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-03-20 11:04   ` bug#54459: 29.0.50; Simplify connection-local variables (feature request) Michael Albinus
2022-03-20 12:09     ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-20 18:17       ` Michael Albinus
2022-03-29  8:25         ` Michael Albinus
2022-03-29 12:01           ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-03-29 13:11             ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bky2zjzz.fsf@aol.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=54459@debbugs.gnu.org \
    --cc=spacibba@aol.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.