From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#54459: 29.0.50; Simplify connection-local variables (feature request) Date: Sat, 19 Mar 2022 04:41:52 +0100 Message-ID: <87bky2zjzz.fsf@aol.com> References: <87bky2zjzz.fsf.ref@aol.com> Reply-To: Ergus Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22129"; mail-complaints-to="usenet@ciao.gmane.io" To: 54459@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 19 04:43:12 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nVPzj-0005bW-Az for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Mar 2022 04:43:11 +0100 Original-Received: from localhost ([::1]:54146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVPzh-00080H-Sh for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Mar 2022 23:43:09 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVPza-0007zu-Rc for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2022 23:43:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36686) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVPza-0000eS-JB for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2022 23:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nVPza-0008PO-Ee for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2022 23:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ergus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Mar 2022 03:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54459 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.164766137332303 (code B ref -1); Sat, 19 Mar 2022 03:43:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Mar 2022 03:42:53 +0000 Original-Received: from localhost ([127.0.0.1]:58816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nVPzR-0008Ox-0w for submit@debbugs.gnu.org; Fri, 18 Mar 2022 23:42:53 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:59822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nVPzP-0008On-ET for submit@debbugs.gnu.org; Fri, 18 Mar 2022 23:42:52 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVPzP-0007zB-7Z for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2022 23:42:51 -0400 Original-Received: from sonic304-56.consmr.mail.bf2.yahoo.com ([74.6.128.31]:46436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVPzM-0000dO-Cu for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2022 23:42:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1647661366; bh=g6taiPwswQgJMlYc+mZEoHXu3QYLg4aMVinfXxhIOfI=; h=From:To:Cc:Subject:Date:References:From:Subject:Reply-To; b=cFaohSylXSrvymidBEbQKuQMaNPypZVbCeJaESL2yV7Gxl/y58ToZokIUhiHJ4QufWHDm0Qgt1Y2dqy3aTeeD2KTSBVafE5s+GHsrCW8gT3PTACO+eDxM99MyqsMzIc3QukI83EISA6BtIr/YVF3iePQcNtkjxHfuDxB3MgXB0woWdsi9Tyua+Jlh3PeHF3sAwyubR/oC37mFpeN3Gro0YdfqQeCC01+jRG8FQ2Tg7L5YaAPKz4yHrORG0w/4xJ7lJLIdAWfAW0oA1Z4DTTC6xtQNLZIrZYY2YEZ/MBRca5BXGnVgShrkZWv+kXrtxmkiozeiLO60KK8oiFA29w1UA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1647661366; bh=cPjv78oO/4HMa5N2LI2CVrXzOWPdt4ixrDreq5wzj+N=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=GLqXAM3HkKEY9pwlEvbCKkJmi7Ezf6T2RjK2tYyDquEAgIpPfJDwwVDk3Kz9RJyLmMDKgGNb4/e71GpISXWv1FW0T0+5D2E1/VVUN0tsTfquQvjADIleOsAU28kNio9DwC6JmsIvHSqDMV4oApSUwJtWoG0G9LKsYSp4q1ZyQHtP5KMuwQSWvM1j6AnZ6rhjASLBobhLFRTj54dA7dH87fRqDCs/UZva+KNO0zTCV/Jf/egfZx12F9m+orrflVXllIEwDctKrW1XDBSib9ubqd6VD/2OzOVXzJ5k6gVecETAy6PRLzSjN5KhyfI69bFHBCvtuaz7q7cahm10+4z4Gg== X-YMail-OSG: uSzCtb4VM1nNXsb4LW2tavi5MLXQ.7PsxmS25MonR_eSsq7JIkFiAPtdRU3WbXT nrHKA.3ewOR8Jb2tLSbd.7zlqapc7hobe0UbIoYvsOC0BKhTptmNFEhGi9vM2XQjQtwyKxZmrG1M huuViFLnqKKJIJnW12zIUuD6HDxSOygTxDl7CyXYMwXjMx8ZD.uVZpJFlv2W7B7z9ceQpd8pXgPh uVwgn968poX7P3YypdjYrrEF4ZgHcLiYEPnddtLmih1ID1hj7vktXLVfpIIQrseN1YX7mQv_N92v vWXga0eC48l_XE5_RB18LB302ZAcmCVP5mZE2.CAxc9ANqN.DgXtIPlV.309HXT_9V9U95ytBpfC u_Xx54eTJFJ8qOdz628AEQvRKpQa9zOTUIPz7m4SVDoB36bpi1dDurM_am1WYcL.ivXuLF6Qy3PD K3.hv0m5eu6nI8vrK5RNYQYKyP3pIibOfVEZCIweZxQUD9EOR2zaY7t.4.p77dd9_Qc6dmSf0L_z v6H5PcT80ZJTbeA0GKxBxjFrPqCODJbt2Txyw5IPZRa3IZS5HpxYz4UVlo.Wv0i6Y1_hRxeSmW5X y_0Qk.N2MwgpJwGKPySykKD7bSh1zVvsVBo4YOqJBly_YK3AEVDQAGD2mNXG5K5vbdQxDp6MKIrM yzh4o4B3d2eZQwGJeucK3eu8b4WDSmvMqZV4wQO_pr.zCaDpx5dNoOfgKYT7iInqYylme7X6hu9j MjojtqpoTHki6uhLzkeN.P8xvGTmi_1xJ.FtdUt5qsGtlUHghNCKdTi2vH48R2zUvHG.IGPccLLG 3aVdLQvccS6C8yK9Ys5NtT0C42ZSpt7fjsbesgEd3q X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.bf2.yahoo.com with HTTP; Sat, 19 Mar 2022 03:42:46 +0000 Original-Received: by kubenode516.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 0e343734c1c3e5a7578e880aa32811c5; Sat, 19 Mar 2022 03:42:41 +0000 (UTC) X-Mailer: WebService/1.1.19894 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.128.31; envelope-from=spacibba@aol.com; helo=sonic304-56.consmr.mail.bf2.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:228577 Archived-At: 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))