From cd269753cff7c6018f75e144e414eeea3e8809dc Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 8 Sep 2022 00:24:16 +0200 Subject: [PATCH] fix(lib): leave point at bob in with-file-contents! with-file-contents!'s docstring promises that point will end up at the beginning of the buffer, but this promise wasn't kept until now. --- lisp/lib/files.el | 1 + lisp/lib/system.el | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/lib/files.el b/lisp/lib/files.el index 42d0018bc..770d555e8 100644 --- a/lisp/lib/files.el +++ b/lisp/lib/files.el @@ -342,6 +342,7 @@ optimizations for `binary' IO." (declare (indent 1)) `(doom--with-prepared-file-buffer ,file (or coding-system-for-read 'utf-8) nil (doom-file-read buffer-file-name :by 'insert :coding coding-system-for-read) + (goto-char (point-min)) ,@body)) ;;;###autoload diff --git a/lisp/lib/system.el b/lisp/lib/system.el index 2e7835375..58c6d9a20 100644 --- a/lisp/lib/system.el +++ b/lisp/lib/system.el @@ -8,7 +8,7 @@ (IS-MAC 'macos) ((ignore-errors (with-file-contents! "/etc/os-release" - (when (re-search-backward "^ID=\"?\\([^\"\n]+\\)\"?" nil t) + (when (re-search-forward "^ID=\"?\\([^\"\n]+\\)\"?" nil t) (intern (downcase (match-string 1))))))) ;; A few redundancies in case os-release fails us ((file-exists-p "/etc/debian_version") @@ -37,7 +37,7 @@ (format "NixOS %s" (sh "nixos-version"))) ((ignore-errors (with-file-contents! "/etc/os-release" - (when (re-search-backward "^PRETTY_NAME=\"?\\([^\"\n]+\\)\"?" nil t) + (when (re-search-forward "^PRETTY_NAME=\"?\\([^\"\n]+\\)\"?" nil t) (match-string 1))))) ((when-let (files (doom-glob "/etc/*-release")) (truncate-string-to-width