summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-01-06 22:55:26 -0600
committerCase Duckworth2022-01-06 22:55:26 -0600
commitf0294f7fb4de3fed7e3f14969ebaa1531193361e (patch)
treea05537b5d8a64e46e2d8111f483ceaaa30d4ddcc /lisp
parentAdd god-mode (diff)
downloademacs-f0294f7fb4de3fed7e3f14969ebaa1531193361e.tar.gz
emacs-f0294f7fb4de3fed7e3f14969ebaa1531193361e.zip
Lots of other changes
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw.el50
1 files changed, 50 insertions, 0 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index 8b9c7b9..9361cdf 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -185,5 +185,55 @@ three blank lines, then place the point on the second one."
185 (newline 2) 185 (newline 2)
186 (previous-line))) 186 (previous-line)))
187 187
188(defun +split-window-then (&optional where arg)
189 "Split the window into a new buffer.
190With non-nil ARG (\\[universal-argument] interactively), don't
191prompt for a buffer to switch to. This function will split the
192window using `split-window-sensibly', or open the new window in
193the direction specified by WHERE. WHERE is ignored when called
194interactively; if you want specific splitting, use
195`+split-window-right-then' or `+split-window-below-then'."
196 (interactive "i\nP")
197 ;; TODO: Canceling at the switching phase leaves the point in the other
198 ;; window. Ideally, the user would see this as one action, meaning a cancel
199 ;; would return to the original window.
200 (pcase where
201 ;; These directions are 'backward' to the OG Emacs split-window commands,
202 ;; because by default Emacs leaves the cursor in the original window. Most
203 ;; users probably expect a switch to the new window, at least I do.
204 ((or 'right :right) (split-window-right) (other-window 1))
205 ((or 'left :left) (split-window-right))
206 ((or 'below :below) (split-window-below) (other-window 1))
207 ((or 'above :above) (split-window-below))
208 ((pred null)
209 (or (split-window-sensibly)
210 (if (< (window-height) (window-width))
211 (split-window-below)
212 (split-window-right)))
213 (other-window 1))
214 (_ (user-error "Unknown WHERE paramater: %s" where)))
215 (unless arg
216 (condition-case nil
217 (call-interactively
218 (pcase (read-char "(B)uffer or (F)ile?")
219 (?b (if (fboundp #'consult-buffer)
220 #'consult-buffer
221 #'switch-to-buffer))
222 (?f #'find-file)
223 (_ #'ignore)))
224 (quit (delete-window)))))
225
226(defun +split-window-right-then (&optional arg)
227 "Split window right, then prompt for a new buffer.
228With optional ARG (\\[universal-argument]), just split."
229 (interactive "P")
230 (+split-window-then :right arg))
231
232(defun +split-window-below-then (&optional arg)
233 "Split window below, then prompt for a new buffer.
234With optional ARG (\\[universal-argument]), just split."
235 (interactive "P")
236 (+split-window-then :below arg))
237
188(provide 'acdw) 238(provide 'acdw)
189;;; acdw.el ends here 239;;; acdw.el ends here