From 93679b7ddce3d5c5f89e97ec000f3fc65d79abbe Mon Sep 17 00:00:00 2001 From: dickmao Date: Fri, 30 Jul 2021 15:03:00 -0400 Subject: [PATCH] set-visited-file-name side effects Commit 606b783acb leverages a 2015 hack that extracts the package version from the buffer file name, only he has to explicitly `set-visited-file-name` to do it. `set-visited-file-name` has the adverse side effect of changing the default-directory, and that causes me problems. If the ostensible reason for bug#48137 was to get the "lm" functions dos-aware, then why not do that instead of applying a workaround on top of a hack? * lisp/emacs-lisp/lisp-mnt.el (lm-header): Fix the thing that you wanted to fix. * lisp/emacs-lisp/package.el (package-install-file): Avoid changing the default directory. * test/lisp/emacs-lisp/package-tests.el (package-test-install-file-EOLs): What is "mac" encoding? It doesn't work. The names of salient coding systems do not coincide with the predominant desktop operating systems. --- lisp/emacs-lisp/lisp-mnt.el | 2 +- lisp/emacs-lisp/package.el | 1 - test/lisp/emacs-lisp/package-tests.el | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el index 83da495edf..e16875140b 100644 --- a/lisp/emacs-lisp/lisp-mnt.el +++ b/lisp/emacs-lisp/lisp-mnt.el @@ -264,7 +264,7 @@ lm-header (if (save-excursion (skip-chars-backward "^$" (match-beginning 0)) (= (point) (match-beginning 0))) - "[^\n]+" "[^$\n]+"))) + "[^\r\n]+" "[^$\r\n]+"))) (match-string-no-properties 0)))) (defun lm-header-multiline (header) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index f1daa8d124..2ea932ee58 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2238,7 +2238,6 @@ package-install-file (setq default-directory file) (dired-mode)) (insert-file-contents-literally file) - (set-visited-file-name file) (when (string-match "\\.tar\\'" file) (tar-mode))) (package-install-from-buffer))) diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el index 2943579955..95bccd4a3f 100644 --- a/test/lisp/emacs-lisp/package-tests.el +++ b/test/lisp/emacs-lisp/package-tests.el @@ -296,7 +296,7 @@ package-test-install-file-EOLs (insert-file-contents source-file) (let (hashes) - (dolist (coding '(unix dos mac) hashes) + (dolist (coding '(unix dos) hashes) (let* ((eol-file (expand-file-name pkg-el package-test-user-dir))) ;; save package with this EOL convention. (set-buffer-file-coding-system coding) @@ -318,7 +318,7 @@ package-test-install-file-EOLs (let* ((descr (cadr (assq 'simple-single package-alist))) (pkg-dir (package-desc-dir descr)) - (dest-file (expand-file-name "simple-single.el" pkg-dir )) + (dest-file (expand-file-name "simple-single.el" pkg-dir)) (dest-hash (with-temp-buffer (insert-file-contents-literally dest-file) (buffer-hash)))) -- 2.26.2