From 7f8f19da2492cd11b984c67259bfb645984d9c06 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 6 Feb 2023 18:28:21 +0200 Subject: [PATCH] Fix 'hack-local-variables' when EOL conversion is inhibited * lisp/files.el (hack-local-variables--find-variables): Replace CRs with newlines only if the original buffer is under explicit selective-display. (Bug#61321) --- lisp/files.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/files.el b/lisp/files.el index 9da82446112..b0ec6bb09d0 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -4017,6 +4017,7 @@ major-mode." (forward-line 1) (let ((startpos (point)) endpos + (selective-p (eq selective-display t)) (thisbuf (current-buffer))) (save-excursion (unless (let ((case-fold-search t)) @@ -4033,7 +4034,8 @@ major-mode." (with-temp-buffer (insert-buffer-substring thisbuf startpos endpos) (goto-char (point-min)) - (subst-char-in-region (point) (point-max) ?\^m ?\n) + (if selective-p + (subst-char-in-region (point) (point-max) ?\r ?\n)) (while (not (eobp)) ;; Discard the prefix. (if (looking-at prefix) -- 2.39.5