Compare commits
No commits in common. "92ff95b2e6595f6d6f64a3ba2610a2041dedd9a5" and "b5be01b19ace132d08863f88688cdefe73de4818" have entirely different histories.
92ff95b2e6
...
b5be01b19a
18
init.el
18
init.el
@ -408,6 +408,23 @@
|
|||||||
(display-buffer-reuse-window
|
(display-buffer-reuse-window
|
||||||
display-buffer-pop-up-window)))
|
display-buffer-pop-up-window)))
|
||||||
|
|
||||||
|
;; Inspired by masteringemacs and
|
||||||
|
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Frame-Layouts-with-Side-Windows.html
|
||||||
|
(add-to-list 'display-buffer-alist
|
||||||
|
'("^\\*eshell-side\\*"
|
||||||
|
display-buffer-in-side-window
|
||||||
|
(side . bottom)
|
||||||
|
(slot . -1)
|
||||||
|
(window-height . 0.33)
|
||||||
|
(window-parameters . ((no-other-window . t)))))
|
||||||
|
(add-to-list 'display-buffer-alist
|
||||||
|
'("^\\*shell-side\\*"
|
||||||
|
display-buffer-in-side-window
|
||||||
|
(side . bottom)
|
||||||
|
(slot . 1)
|
||||||
|
(window-height . 0.33)
|
||||||
|
(window-parameters . ((no-other-window . t)))))
|
||||||
|
|
||||||
(add-to-list 'display-buffer-alist
|
(add-to-list 'display-buffer-alist
|
||||||
'("shell\\*"
|
'("shell\\*"
|
||||||
(display-buffer-reuse-window
|
(display-buffer-reuse-window
|
||||||
@ -458,6 +475,7 @@ split horizontally again, but this extra work should not matter much."
|
|||||||
|
|
||||||
(use-package db-utils
|
(use-package db-utils
|
||||||
:commands (endless/fill-or-unfill
|
:commands (endless/fill-or-unfill
|
||||||
|
db/run-or-hide-shell
|
||||||
db/gnus
|
db/gnus
|
||||||
db/org-agenda
|
db/org-agenda
|
||||||
db/scratch
|
db/scratch
|
||||||
|
|||||||
@ -36,13 +36,11 @@ eshell buffer."
|
|||||||
(let ((current-dir (expand-file-name default-directory)))
|
(let ((current-dir (expand-file-name default-directory)))
|
||||||
(cl-flet ((in-eshell-buffer-p ()
|
(cl-flet ((in-eshell-buffer-p ()
|
||||||
(and (derived-mode-p 'eshell-mode)
|
(and (derived-mode-p 'eshell-mode)
|
||||||
(string-match-p "^\\*eshell\\*" (buffer-name)))))
|
(string-match-p "^\\*eshell-side\\*" (buffer-name)))))
|
||||||
|
|
||||||
(if (and (not arg)
|
(if (and (not arg)
|
||||||
(in-eshell-buffer-p))
|
(in-eshell-buffer-p))
|
||||||
(progn
|
(bury-buffer)
|
||||||
(bury-buffer)
|
|
||||||
(delete-window))
|
|
||||||
|
|
||||||
(unless (in-eshell-buffer-p)
|
(unless (in-eshell-buffer-p)
|
||||||
(if-let ((eshell-window (cl-find-if (lambda (window)
|
(if-let ((eshell-window (cl-find-if (lambda (window)
|
||||||
@ -51,7 +49,7 @@ eshell buffer."
|
|||||||
(window-list-1))))
|
(window-list-1))))
|
||||||
(select-window eshell-window)
|
(select-window eshell-window)
|
||||||
;; No running eshell found, open new one.
|
;; No running eshell found, open new one.
|
||||||
(--if-let (display-buffer (let ((eshell-buffer-name "*eshell*")) (eshell)))
|
(--if-let (display-buffer (let ((eshell-buffer-name "*eshell-side*")) (eshell)))
|
||||||
(select-window it)
|
(select-window it)
|
||||||
(error "Could not start eshell (`display-buffer' returned nil)"))))
|
(error "Could not start eshell (`display-buffer' returned nil)"))))
|
||||||
|
|
||||||
|
|||||||
@ -90,6 +90,42 @@ If already in *ansi-term* buffer, bury it."
|
|||||||
(user-error "Cannot open default refile file: file «%s» does not exist" db/org-default-refile-file))
|
(user-error "Cannot open default refile file: file «%s» does not exist" db/org-default-refile-file))
|
||||||
(find-file db/org-default-refile-file))
|
(find-file db/org-default-refile-file))
|
||||||
|
|
||||||
|
(defun db/run-or-hide-shell (arg)
|
||||||
|
"Opens a shell buffer in new window if not already in one.
|
||||||
|
|
||||||
|
Otherwise, closes the current shell window.
|
||||||
|
|
||||||
|
The buffer's name has to start with “*shell-side*” to be recognized by
|
||||||
|
this function. Otherwise the current buffer is not treated as a shell
|
||||||
|
buffer.
|
||||||
|
|
||||||
|
With ARG, switch to `default-directory' of the current buffer first."
|
||||||
|
(interactive "P")
|
||||||
|
(cl-flet ((change-to-shell ()
|
||||||
|
(if-let ((shell-window (cl-find-if (lambda (window)
|
||||||
|
(with-current-buffer (window-buffer window)
|
||||||
|
(and (derived-mode-p 'shell-mode)
|
||||||
|
(string-match-p "^\\*shell-side\\*" (buffer-name)))))
|
||||||
|
(window-list-1))))
|
||||||
|
(select-window shell-window)
|
||||||
|
(--if-let (display-buffer (shell (get-buffer-create "*shell-side*")))
|
||||||
|
(select-window it)
|
||||||
|
(error "Could not start shell (`display-buffer' returned nil)")))))
|
||||||
|
(if (not arg)
|
||||||
|
;; toggle shell window
|
||||||
|
(if (and (derived-mode-p 'shell-mode)
|
||||||
|
(string-match-p "^\\*shell-side\\*" (buffer-name)))
|
||||||
|
(bury-buffer)
|
||||||
|
(change-to-shell))
|
||||||
|
|
||||||
|
;; unconditionally go to shell, and also change to cwd
|
||||||
|
(let ((current-dir (expand-file-name default-directory)))
|
||||||
|
(change-to-shell)
|
||||||
|
(end-of-line)
|
||||||
|
(comint-kill-input)
|
||||||
|
(insert (format "cd '%s'" current-dir))
|
||||||
|
(comint-send-input)))))
|
||||||
|
|
||||||
(defun db/ement-connect ()
|
(defun db/ement-connect ()
|
||||||
"Connect to my matrix account."
|
"Connect to my matrix account."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user