aboutsummaryrefslogtreecommitdiff
path: root/evil-commands.el
diff options
context:
space:
mode:
authorAxel Forsman <axelsfor@gmail.com>2023-01-06 14:23:15 +0100
committerAxel Forsman <axelsfor@gmail.com>2023-01-10 21:25:44 +0100
commitf003ca28a9691d24a17866e5dce3e7866c9bb257 (patch)
tree02b9f5f7f998fcdbe4db0e61d4019cf61f3b2606 /evil-commands.el
parent24c9c4255a27f9d87b880d2ba4fd1d7df4502075 (diff)
Fix Fundamental mode hack
This commit fixes some issues surrounding the initialization of Evil. First of all, since GNU Emacs 26.1 major mode hooks actually do run in Fundamental mode buffers. In any case, manually enabling fundamental-mode correctly instead of turn-on-evil-mode (by setting major-mode default) successfully enables evil-local-mode, as major mode hooks then run. The major-mode variable also never needed to be reset; it is the job of the major mode to set it, as it starts off as fundamental-mode regardless of its default value. Secondly, while some hooks and variables set up by evil-local-mode were marked as permanent, this did not matter as evil-initialize unconditionally reinitialized evil-local-mode whenever the major mode changed. Fixed by marking them all as permanent and not executing evil-local-mode if it is already enabled. Closes #1268, closes #1561
Diffstat (limited to 'evil-commands.el')
-rw-r--r--evil-commands.el72
1 files changed, 29 insertions, 43 deletions
diff --git a/evil-commands.el b/evil-commands.el
index 03fd063..3f9b5ab 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -706,29 +706,27 @@ Movement is restricted to the current line unless `evil-cross-lines' is non-nil.
(setq count (or count 1))
(let ((fwd (> count 0))
(visual (and evil-respect-visual-line-mode
- visual-line-mode)))
+ visual-line-mode))
+ case-fold-search)
(setq evil-last-find (list #'evil-find-char char fwd))
(when fwd (evil-forward-char 1 evil-cross-lines))
- (let ((case-fold-search nil))
- (unless (prog1
- (search-forward (char-to-string char)
- (cond (evil-cross-lines
- nil)
- ((and fwd visual)
- (save-excursion
- (end-of-visual-line)
- (point)))
- (fwd
- (line-end-position))
- (visual
- (save-excursion
- (beginning-of-visual-line)
- (point)))
- (t
- (line-beginning-position)))
- t count)
- (when fwd (backward-char)))
- (user-error "Can't find %c" char)))))
+ (unless (prog1
+ (search-forward
+ (char-to-string char)
+ (cond (evil-cross-lines nil)
+ ((and fwd visual)
+ (save-excursion
+ (end-of-visual-line)
+ (point)))
+ (fwd (line-end-position))
+ (visual
+ (save-excursion
+ (beginning-of-visual-line)
+ (point)))
+ (t (line-beginning-position)))
+ t count)
+ (when fwd (backward-char)))
+ (user-error "Can't find `%c'" char))))
(evil-define-motion evil-find-char-backward (count char)
"Move to the previous COUNT'th occurrence of CHAR."
@@ -4476,13 +4474,8 @@ and open a new buffer or edit a certain FILE."
(if evil-split-window-below 'below 'above))))
(when (and (not count) evil-auto-balance-windows)
(balance-windows (window-parent)))
- (let ((buffer (generate-new-buffer "*new*")))
- (set-window-buffer new-window buffer)
- (select-window new-window)
- (with-current-buffer buffer
- (funcall (default-value 'major-mode))))
- (when file
- (evil-edit file))))
+ (select-window new-window)
+ (evil-buffer-new file)))
(evil-define-command evil-window-vnew (count file)
"Split the current window vertically
@@ -4493,25 +4486,18 @@ and open a new buffer name or edit a certain FILE."
(if evil-vsplit-window-right 'right 'left))))
(when (and (not count) evil-auto-balance-windows)
(balance-windows (window-parent)))
- (let ((buffer (generate-new-buffer "*new*")))
- (set-window-buffer new-window buffer)
- (select-window new-window)
- (with-current-buffer buffer
- (funcall (default-value 'major-mode))))
- (when file
- (evil-edit file))))
-
-(evil-define-command evil-buffer-new (count file)
- "Create a new buffer replacing the current window, optionally
- editing a certain FILE"
+ (select-window new-window)
+ (evil-buffer-new file)))
+
+(evil-define-command evil-buffer-new (&optional file)
+ "Edit a new unnamed buffer or FILE."
:repeat nil
- (interactive "P<f>")
+ (interactive "<f>")
(if file
(evil-edit file)
(let ((buffer (generate-new-buffer "*new*")))
- (set-window-buffer nil buffer)
- (with-current-buffer buffer
- (funcall (default-value 'major-mode))))))
+ (set-buffer-major-mode buffer)
+ (set-window-buffer nil buffer))))
(evil-define-command evil-window-increase-height (count)
"Increase current window height by COUNT."