* bug#54459: 29.0.50; Simplify connection-local variables (feature request) [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 2022-03-20 11:04 ` Michael Albinus 0 siblings, 1 reply; 7+ messages in thread From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-19 3:41 UTC (permalink / raw) To: 54459 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)) ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#54459: 29.0.50; Simplify connection-local variables (feature request) 2022-03-19 3:41 ` bug#54459: 29.0.50; Simplify connection-local variables (feature request) Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-20 11:04 ` Michael Albinus 2022-03-20 12:09 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 1 reply; 7+ messages in thread From: Michael Albinus @ 2022-03-20 11:04 UTC (permalink / raw) To: 54459; +Cc: spacibba Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> writes: > Hi: Hi, > 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? I don't understand the scenario, sorry. Could you pls explain it in detail? > 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. --8<---------------cut here---------------start------------->8--- (connection-local-set-profile-variables 'profile (append (connection-local-get-profile-variables 'profile) my-variables-list)) --8<---------------cut here---------------end--------------->8--- > 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. That's hard to do. A user could change the remote PATH while the result of executable-find is cached. Furthermore, Tramp appends the local part of the remote default-directory to the directory search list. Therefore, executable-find could return a possibly wrong cached value. You could write your own function, using Tramp's cache mechanism, but at your own risk. Something like (untested) --8<---------------cut here---------------start------------->8--- (defun my-executable-find (command &optional remote) (if (and remote (file-remote-p default-directory)) (with-tramp-connection-property (tramp-get-process (tramp-dissect-file-name default-directory)) (concat "executable-find-" command) (executable-find command remote)) (executable-find command remote))) --8<---------------cut here---------------end--------------->8--- Best regards, Michael. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#54459: 29.0.50; Simplify connection-local variables (feature request) 2022-03-20 11:04 ` 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 0 siblings, 1 reply; 7+ messages in thread From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-20 12:09 UTC (permalink / raw) To: Michael Albinus; +Cc: 54459 On Sun, Mar 20, 2022 at 12:04:28PM +0100, Michael Albinus wrote: >Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text >editors" <bug-gnu-emacs@gnu.org> writes: > >> Hi: > >Hi, > >> 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? > >I don't understand the scenario, sorry. Could you pls explain it in detail? > Suppose: C-x C-f /ssh:myhost:file1 C-x C-f /ssh:myhost:file2 (executable-find mycommand 1) And here we set the connection local variable... When we go to file1 if does not know about the variable in spite of it is in the same host. >> 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. > >--8<---------------cut here---------------start------------->8--- >(connection-local-set-profile-variables > 'profile > (append > (connection-local-get-profile-variables 'profile) > my-variables-list)) >--8<---------------cut here---------------end--------------->8--- > Could you consider to add a snippet in the documentation explaining this? Please? >> 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. > >That's hard to do. A user could change the remote PATH while the result >of executable-find is cached. Furthermore, Tramp appends the local part >of the remote default-directory to the directory search list. SO this means that the executable in default-directory are also considered? Like on Windows? I was not aware of that... >Therefore, >executable-find could return a possibly wrong cached value. > >You could write your own function, using Tramp's cache mechanism, but at >your own risk. Something like (untested) > >--8<---------------cut here---------------start------------->8--- >(defun my-executable-find (command &optional remote) > (if (and remote (file-remote-p default-directory)) > (with-tramp-connection-property > (tramp-get-process (tramp-dissect-file-name default-directory)) > (concat "executable-find-" command) > (executable-find command remote)) > (executable-find command remote))) >--8<---------------cut here---------------end--------------->8--- > I was thinking in something like: (executable-find command &optional remote cache) but basically the same idea. But it was just a dream... A man can dream, a man can dream ;p >Best regards, Michael. Thanks, Ergus ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#54459: 29.0.50; Simplify connection-local variables (feature request) 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 0 siblings, 1 reply; 7+ messages in thread From: Michael Albinus @ 2022-03-20 18:17 UTC (permalink / raw) To: Ergus; +Cc: 54459 Ergus <spacibba@aol.com> writes: Hi, > Suppose: > > C-x C-f /ssh:myhost:file1 > C-x C-f /ssh:myhost:file2 > (executable-find mycommand 1) > And here we set the connection local variable... > > When we go to file1 if does not know about the variable in spite of it > is in the same host. I recommend to move the code setting connection-local variables in a funcion called by a hook, which is applied when visiting files in your use case. >>--8<---------------cut here---------------start------------->8--- >>(connection-local-set-profile-variables >> 'profile >> (append >> (connection-local-get-profile-variables 'profile) >> my-variables-list)) >>--8<---------------cut here---------------end--------------->8--- >> > Could you consider to add a snippet in the documentation explaining > this? Please? Done in the Elisp manual, pushed to master as commit aec44a5be3. >>That's hard to do. A user could change the remote PATH while the result >>of executable-find is cached. Furthermore, Tramp appends the local part >> of the remote default-directory to the directory search list. > > SO this means that the executable in default-directory are also > considered? Like on Windows? I was not aware of that... Well, this is rather an implementation detail, not documented. And I'm not sure it is the best decision, we just needed a last element in exec-path which is comparable to the last element in the local case of exec-path. >>You could write your own function, using Tramp's cache mechanism, but at >>your own risk. Something like (untested) >> >>--8<---------------cut here---------------start------------->8--- >>(defun my-executable-find (command &optional remote) >> (if (and remote (file-remote-p default-directory)) >> (with-tramp-connection-property >> (tramp-get-process (tramp-dissect-file-name default-directory)) >> (concat "executable-find-" command) >> (executable-find command remote)) >> (executable-find command remote))) >>--8<---------------cut here---------------end--------------->8--- >> > I was thinking in something like: > > (executable-find command &optional remote cache) but basically the same idea. This cannot be generalized, the code uses Tramp specific functions. A remote file name does not always mean invoking Tramp ... > Thanks, > Ergus Best regards, Michael. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#54459: 29.0.50; Simplify connection-local variables (feature request) 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 0 siblings, 1 reply; 7+ messages in thread From: Michael Albinus @ 2022-03-29 8:25 UTC (permalink / raw) To: Ergus; +Cc: 54459 Hi, hmm, are there still open points? Otherwise I'd like to close the bug. Best regards, Michael. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#54459: 29.0.50; Simplify connection-local variables (feature request) 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 0 siblings, 1 reply; 7+ messages in thread From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-29 12:01 UTC (permalink / raw) To: Michael Albinus; +Cc: 54459 On Tue, Mar 29, 2022 at 10:25:01AM +0200, Michael Albinus wrote: >Hi, > >hmm, are there still open points? Otherwise I'd like to close the bug. > >Best regards, Michael. As you added the documentation for it, please, close it then. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#54459: 29.0.50; Simplify connection-local variables (feature request) 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 0 siblings, 0 replies; 7+ messages in thread From: Michael Albinus @ 2022-03-29 13:11 UTC (permalink / raw) To: Ergus; +Cc: 54459-done Version: 29.1 Ergus <spacibba@aol.com> writes: > On Tue, Mar 29, 2022 at 10:25:01AM +0200, Michael Albinus wrote: >>Hi, >> >>hmm, are there still open points? Otherwise I'd like to close the bug. >> >>Best regards, Michael. > > As you added the documentation for it, please, close it then. Done. Best regards, Michael. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-03-29 13:11 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <87bky2zjzz.fsf.ref@aol.com> 2022-03-19 3:41 ` bug#54459: 29.0.50; Simplify connection-local variables (feature request) Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors 2022-03-20 11:04 ` 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
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.