From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Braun =?UTF-8?Q?G=C3=A1bor?= Newsgroups: gmane.emacs.bugs Subject: bug#38179: 26.1; clone-buffer globally unsets locally void variable Date: Tue, 12 Nov 2019 16:16:16 +0100 Message-ID: <10286828.kQ2LJabMkc@gabor> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="159450"; mail-complaints-to="usenet@blaine.gmane.org" To: 38179@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 12 16:17:28 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iUXv6-000fLn-JV for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Nov 2019 16:17:28 +0100 Original-Received: from localhost ([::1]:36428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUXv5-0003MS-Go for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Nov 2019 10:17:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42169) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUXum-0003M8-BC for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 10:17:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUXuk-0001QM-8d for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 10:17:08 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49355) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUXuj-0001Q4-UM for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 10:17:06 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iUXuj-0001zr-Fc for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 10:17:05 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Braun =?UTF-8?Q?G=C3=A1bor?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Nov 2019 15:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 38179 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.15735717987630 (code B ref -1); Tue, 12 Nov 2019 15:17:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Nov 2019 15:16:38 +0000 Original-Received: from localhost ([127.0.0.1]:58175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iUXuH-0001yz-FE for submit@debbugs.gnu.org; Tue, 12 Nov 2019 10:16:38 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:53094) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iUXuD-0001yo-JK for submit@debbugs.gnu.org; Tue, 12 Nov 2019 10:16:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42104) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUXuB-0003LE-N5 for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 10:16:33 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUXuA-0001AZ-32 for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 10:16:31 -0500 Original-Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:45496) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUXu9-00019Q-Q0 for bug-gnu-emacs@gnu.org; Tue, 12 Nov 2019 10:16:30 -0500 Original-Received: by mail-wr1-x432.google.com with SMTP id z10so13639528wrs.12 for ; Tue, 12 Nov 2019 07:16:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=GjDgbzlb/rLy6jy8zJqcPZEib/7igHX2okFyBfk3HMs=; b=WiQBzP80jd5lB7U7YHbgKiJjKRql5vgtak/HP0a0y+xR4+FmCeVD1Fr3OT1r9wvNvL bDWfT6Yo9AD1HI/OUlJivTUl4h3wU1ZCEoX3th0swbsZvNWXCvkJ/1X2mURcWNFsDQYV W1QScDHVQx6MNI5fQrIUMw6mp2M9PDHNMha1bPV00cHV2aJQKd/US8mGidVKBCEZq2Sc jJjAFq4jH0s43c3BiFiHQUSytYoCH5x5rYSkdxkU5VVnwgSQ73We/h5GsBmvyAriOURw A6M6YxxhE3hR5yaqT7f8VQWE9aINyiPoxe3OxrSNXnASHNNBk5ydtIKBFwpcYuHTt68d 6WCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=GjDgbzlb/rLy6jy8zJqcPZEib/7igHX2okFyBfk3HMs=; b=m1DTkaavYwRkv6QUVvvtmX7tkEM1doiZJJGnnXisznDTtdLCN3w3XwpDeQ7UWE52eG 4W2/UG8YUwj4kjELnxlQGe8A8we5yHu5d5EPgd1kZt3XCxISHZLxKJxt+PBuce2Rdeo7 j3Ym1rU4Q2WlbDt5HkrJDZuRzWNpphgBrLW2k8umCh4RhOlFknOp5dL9jiQw4BHw8BYr WEIVL/z4ofT0rsyLsM0luM6MYy5VpMjpr3B7EMPqauN5LqB5OQsWaU8qZueWn2EPKLPj +6RpC5vfI03goLH4S2H4vMcBu0G7oG7FRzvjU3qH9gF1bfI9vgFMzgvLdZP20F8tWw47 AykA== X-Gm-Message-State: APjAAAUocPpLGE6RPWs2h9Hq0CO8S9hbqyJGjCLGpbmBEP3HMViM9v0i iOn9LSSv0ord30IqqqSa3Gx346uS X-Google-Smtp-Source: APXvYqyxN/+C+MuCsbuYXQ6eASaUJ8Zz056xjTmRCfJiboFwbEfTBZpFNJv+jiEpSYsdUlWQEvDpLA== X-Received: by 2002:a5d:694d:: with SMTP id r13mr24729623wrw.395.1573571787960; Tue, 12 Nov 2019 07:16:27 -0800 (PST) Original-Received: from gabor.localnet (254C4FA9.nat.pool.telekom.hu. [37.76.79.169]) by smtp.gmail.com with ESMTPSA id x6sm19157004wrw.34.2019.11.12.07.16.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2019 07:16:26 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:171457 Archived-At: Hi, * Idea: Let's create a test, which sets the default value of a variable but undefines it locally in some buffer. Then clone the buffer and check that the default value of the variable is unchanged, and it is locally undefined in both the original buffer and the clone. * Recipe to reproduce the bug: Create test.el with the following content (there is no empty line in the file): (ert-deftest clone-buffer-unbound-local-variable () "Test `clone-buffer' on locally unbound variables." (let ((var (make-symbol "test"))) (set-default var 1) (with-temp-buffer (makunbound (make-local-variable var)) (let ((buffer (current-buffer)) (clone (clone-buffer))) (unwind-protect (progn (should (eq (default-value var) 1)) (should-not (boundp var)) (with-current-buffer clone (should-not (boundp var)))) (when (buffer-live-p clone) (kill-buffer clone))))))) Run the test: $ emacs -Q -batch -l ert -l test.el -f ert-run-tests-batch-and-exit Running 1 tests (2019-11-12 15:55:39+0100) Test clone-buffer-unbound-local-variable backtrace: signal(void-variable (test)) apply(signal (void-variable (test))) (setq value-2 (apply fn-0 args-1)) (unwind-protect (setq value-2 (apply fn-0 args-1)) (setq form-descri (if (unwind-protect (setq value-2 (apply fn-0 args-1)) (setq form-de (let (form-description-4) (if (unwind-protect (setq value-2 (apply f (let ((value-2 'ert-form-evaluation-aborted-3)) (let (form-descripti (let* ((fn-0 (function eq)) (args-1 (condition-case err (let ((signa (progn (let* ((fn-0 (function eq)) (args-1 (condition-case err (let (unwind-protect (progn (let* ((fn-0 (function eq)) (args-1 (conditio (let ((buffer (current-buffer)) (clone (clone-buffer))) (unwind-prot (progn (makunbound (make-local-variable var)) (let ((buffer (current (unwind-protect (progn (makunbound (make-local-variable var)) (let ( (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-b (let ((var (make-symbol "test"))) (set-default var 1) (let ((temp-bu (lambda nil (let ((var (make-symbol "test"))) (set-default var 1) (l ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test ert-run-test(#s(ert-test :name clone-buffer-unbound-local-variable : ert-run-or-rerun-test(#s(ert--stats :selector t :tests [#s(ert-test ert-run-tests(t #f(compiled-function (event-type &rest event-args) # ert-run-tests-batch(nil) ert-run-tests-batch-and-exit() command-line-1(("-l" "ert" "-l" "test.el" "-f" "ert-run-tests-batch- command-line() normal-top-level() Test clone-buffer-unbound-local-variable condition: (void-variable test) FAILED 1/1 clone-buffer-unbound-local-variable Ran 1 tests, 0 results as expected, 1 unexpected (2019-11-12 15:55:40+0100) 1 unexpected results: FAILED clone-buffer-unbound-local-variable The test failed but it should pass. * Patch to fix the problem When copying buffer local variables, make even undefined variables buffer local before undefining them: =2D-- lisp/simple.el +++ lisp/simple.el @@ -8535,7 +8535,7 @@ (mapc (lambda (v) (condition-case () ;in case var is read-only (if (symbolp v) =2D (makunbound v) + (makunbound (make-local-variable v)) (set (make-local-variable (car v)) (cdr v))) (error nil))) lvars) Best wishes, G=C3=A1bor In GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.4) of 2019-02-03, modified by Debian built on zam904 Windowing system distributor 'The X.Org Foundation', version 11.0.12004000 System Description: Debian GNU/Linux 10 (buster) Recent messages: =46or information about GNU Emacs and the GNU system, type C-h C-a. Ran 1 tests, 0 results were as expected, 1 unexpected scroll-up-command: End of buffer Configured using: 'configure --build x86_64-linux-gnu --prefix=3D/usr --sharedstatedir=3D/var/lib --libexecdir=3D/usr/lib --localstatedir=3D/var/lib --infodir=3D/usr/share/info --mandir=3D/usr/share/man --enable-libsystemd --with-pop=3Dyes --enable-locallisppath=3D/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:= /usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share= /emacs/site-lisp --with-sound=3Dalsa --without-gconf --with-mailutils --build x86_64-linux-gnu --prefix=3D/usr --sharedstatedir=3D/var/lib --libexecdir=3D/usr/lib --localstatedir=3D/var/lib --infodir=3D/usr/share/info --mandir=3D/usr/share/man --enable-libsystemd --with-pop=3Dyes --enable-locallisppath=3D/etc/emacs:/usr/local/share/emacs/26.1/site-lisp:= /usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/usr/share= /emacs/site-lisp --with-sound=3Dalsa --without-gconf --with-mailutils --with-x=3Dyes --with-x-toolkit=3Dgtk3 --with-toolkit-scroll-bars 'CFLAGS=3D-g -O2 -fdebug-prefix-map=3D/build/emacs-26.1+1=3D. -fstack-protector-strong -Wformat -Werror=3Dformat-security -Wall' 'CPPFLAGS=3D-Wdate-time -D_FORTIFY_SOURCE=3D2' LDFLAGS=3D-Wl,-z,relro' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LIBSYSTEMD LCMS2 Important settings: value of $LANG: hu_HU.UTF-8 locale-coding-system: utf-8-unix Major mode: ERT-Results Minor modes in effect: tooltip-mode: t global-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 buffer-read-only: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. =46eatures: (shadow sort mail-extr emacsbug message rmc puny seq byte-opt bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-seq cl-extra help-mode cl-macs gv ert pp find-func ewoc easymenu debug cl-loaddefs cl-lib elec-pair time-date mule-util 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 menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame 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 minibuffer 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 dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 104606 9545) (symbols 48 21227 1) (miscs 40 55 129) (strings 32 30450 1108) (string-bytes 1 805629) (vectors 16 15583) (vector-slots 8 506210 7590) (floats 8 59 58) (intervals 56 284 0) (buffers 992 12))