From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: David Landell Newsgroups: gmane.emacs.bugs Subject: bug#54405: 27.1; How to reset connection-local variable Date: Tue, 15 Mar 2022 21:44:49 +0100 Message-ID: <867d8vc5dq.fsf@tiefighter.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7903"; mail-complaints-to="usenet@ciao.gmane.io" To: 54405@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 15 21:46:43 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 1nUE42-0001px-QE for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Mar 2022 21:46:42 +0100 Original-Received: from localhost ([::1]:46816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nUE41-0003AL-ED for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Mar 2022 16:46:41 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUE3O-0001yW-DA for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 16:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nUE3N-0000Ia-Vs for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 16:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nUE3N-0002Hq-PS for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 16:46:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: David Landell Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Mar 2022 20:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54405 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.16473771228734 (code B ref -1); Tue, 15 Mar 2022 20:46:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Mar 2022 20:45:22 +0000 Original-Received: from localhost ([127.0.0.1]:49688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUE2k-0002Go-97 for submit@debbugs.gnu.org; Tue, 15 Mar 2022 16:45:22 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:49332) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nUE2i-0002Gg-9d for submit@debbugs.gnu.org; Tue, 15 Mar 2022 16:45:20 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUE2h-0000xJ-Ta for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 16:45:20 -0400 Original-Received: from mailtransmit05.runbox.com ([185.226.149.38]:49476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nUE2f-00007p-Fc for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 16:45:19 -0400 Original-Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1nUE2X-00Bfy7-7a for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 21:45:09 +0100 Original-Received: from [10.9.9.72] (helo=submission01.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1nUE2R-0003gH-Ik for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 21:45:03 +0100 Original-Received: by submission01.runbox with esmtpsa [Authenticated ID (666394)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1nUE2L-0006Mn-A6 for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2022 21:44:57 +0100 Received-SPF: pass client-ip=185.226.149.38; envelope-from=david.landell@sunnyhill.email; helo=mailtransmit05.runbox.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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:228420 Archived-At: --=-=-= Content-Type: text/plain Hi, Is it possible to reset a connection local variable to the default in a buffer when default-directory changes from remote to local? I have attached an example ert test to demonstrate the issue. I would kind of expect the supplied code to work but I may be doing something wrong and there might be some other way of doing this. Couldn't find anything in the manual though. To run the code: emacs -Q -l ./connection-local.el The problem is a real world problem from my package rg.el (https://github.com/dajva/rg.el). It is similar to the grep.el package with the added possibility to rerun a searches with modified parameters from the results buffer. So a typical use case would be to do a search on a remote host and then change the default-directory in the results buffer to do the same search on the local computer. The connection local is used to store the path to the ripgrep executable that is driving the search. Best regards, David Landell --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=connection-local.el Content-Transfer-Encoding: quoted-printable Content-Description: Code to reproduce (require 'ert) (defvar connection-var 'local) (ert-deftest connection-locals-remote->local () ;; Setup connection locals for localhost (connection-local-set-profile-variables 'my-connection-profile '((connection-var . remote))) (connection-local-set-profiles '(:machine "localhost") 'my-connection-pro= file) (with-temp-buffer (setq default-directory (format "/sudo:%s@localhost:%s" (user-login-name) "/tmp")) (hack-connection-local-variables-apply (connection-local-criteria-for-default-directory)) (should (eq connection-var 'remote)) (setq default-directory "/tmp") (hack-connection-local-variables-apply (connection-local-criteria-for-default-directory)) (should (eq connection-var 'local)))) (ert t) --=-=-= Content-Type: text/plain In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2020-09-19 built on lgw01-amd64-021 Windowing system distributor 'The X.Org Foundation', version 11.0.12013000 System Description: Linux Mint 20.2 Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Ran 1 tests, 0 results were as expected, 1 unexpected Making completion list... Configured using: 'configure --build=x86_64-linux-gnu --prefix=/usr '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp --program-suffix=27 --with-modules --with-file-notification=inotify --with-mailutils --with-harfbuzz --with-json --with-x=yes --with-x-toolkit=gtk3 --with-lcms2 --with-cairo --with-xpm=yes --with-gif=yes --with-gnutls=yes --with-jpeg=yes --with-png=yes --with-tiff=yes --with-xwidgets 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/emacs27-bifpWT/emacs27-27.1~1.git86d8d76aa3=. -fstack-protector-strong -Wformat -Werror=format-security -no-pie' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -no-pie'' Configured features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS LIBSYSTEMD JSON PDUMPER LCMS2 GMP Important settings: value of $LC_MONETARY: sv_SE.UTF-8 value of $LC_NUMERIC: sv_SE.UTF-8 value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: shell-dirtrack-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-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 line-number-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs text-property-search 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-cache tramp-sh tramp tramp-loaddefs trampver tramp-integration tramp-compat shell pcomplete comint ansi-color ring parse-time iso8601 time-date ls-lisp format-spec auth-source cl-seq eieio eieio-core eieio-loaddefs password-cache json subr-x map files-x thingatpt cl-extra seq byte-opt bytecomp byte-compile cconv cl-macs gv ert pp ewoc debug backtrace help-mode easymenu find-func cl-loaddefs cl-lib tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu 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 charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting xwidget-internal cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 76214 9618) (symbols 48 9041 1) (strings 32 26513 2007) (string-bytes 1 933622) (vectors 16 15642) (vector-slots 8 191670 10146) (floats 8 60 122) (intervals 56 347 0) (buffers 1000 15)) --=-=-=--