From 2066e827155ae2893097360024ffd975166a44ef Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 23 Jan 2021 00:23:05 +0800 Subject: More custom functions and adjust for custom completion framework * LICENSE: Add GPLv3. * basic.el (durand-enlarge-window): (durand-shrink-window): (durand-enlarge-window-horizontally): (durand-shrink-window-horizontally): Now I can easily maximize or minimize windows. * comb/orderless-conf.el ("orderless"): Now I try to use my own completion framework. * common.el (durand-embark-scroll-down-or-go-to-completions): (durand-embark-scroll-up-or-go-to-completions): (durand-completion-scroll-down-or-go-to-minibuffer): (durand-completion-scroll-up-or-go-to-minibuffer): Move these functions here since they do not belong to the completion framework in my opinion. (register): (register-val-jump-to): Rewrite this method so that it does not have to ask me if I want to open a file while jumping. * completion-conf.el: My intended completion framework, which is still work in progress. * init.el ("comb/orderless-conf.el"): ("completion-conf.el"): Adjust things accordingly. ("durand-simple"): My custom functions for viewing and for opening things. * modeline.el (modeline-propertize): (modeline-format-minor-modes): (modeline-format-major-mode): Now the macro `modeline-propertize' won't override properties that it does not intend to define. This has the effect that the properties of the original constructs will go through and have effect. (modeline-format-main): Make sure the space has a positive length. (modeline-format-buffer-name): Make sure the length does not exceed half the width of the window. --- basic.el | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) (limited to 'basic.el') diff --git a/basic.el b/basic.el index 191c997..b6fd4bf 100644 --- a/basic.el +++ b/basic.el @@ -246,6 +246,80 @@ See `display-line-numbers' for details." ;;; Windows +;;;###autoload +(defun durand-enlarge-window (&optional delta horizontal) + "Make the seleted window DELTA lines taller. + +This is a thin wrapper around the default `enlarge-window'. + +If DELTA is nil, it defaults to 1. + +If HORIZONTAL is non-nil, this will make the seleted window DELTA +lines wider instead. + +If DELTA is negative, shrink instead of enlarge. + +Also, if DELTA is 0, then maximize the selected window." + (interactive "P") + (cond + ((eq delta 0) + (enlarge-window (cond + (horizontal (frame-width)) + ((frame-height))) + horizontal)) + ((enlarge-window (prefix-numeric-value delta) horizontal)))) + +;;;###autoload +(defun durand-shrink-window (&optional delta horizontal) + "Make the seleted window DELTA lines smaller. + +This is a thin wrapper around the default `shrink-window'. + +If DELTA is nil, it defaults to 1. + +If HORIZONTAL is non-nil, this will make the seleted window DELTA +lines smaller instead. + +If DELTA is negative, enlarge instead of shrink. + +Also, if DELTA is 0, then minimize the selected window." + (interactive "p") + (cond + ((eq delta 0) + (shrink-window (cond + (horizontal (frame-width)) + ((frame-height))) + horizontal)) + ((shrink-window (prefix-numeric-value delta) horizontal)))) + +;;;###autoload +(defun durand-enlarge-window-horizontally (&optional delta) + "Make selected window DELTA columns wider. + +This is a thin wrapper around the default `enlarge-window-horizontally'. + +DELTA defaults to 1. If DELTA is 0, then maximize the selected +window horizontally." + (interactive "p") + (cond + ((eq delta 0) + (enlarge-window-horizontally (frame-width))) + ((enlarge-window-horizontally (prefix-numeric-value delta))))) + +;;;###autoload +(defun durand-shrink-window-horizontally (&optional delta) + "Make selected window DELTA columns wider. + +This is a thin wrapper around the default `shrink-window-horizontally'. + +DELTA defaults to 1. If DELTA is 0, then maximize the selected +window horizontally." + (interactive "p") + (cond + ((eq delta 0) + (shrink-window-horizontally (frame-width))) + ((shrink-window-horizontally (prefix-numeric-value delta))))) + (define-key global-map (vector ?\s-o) #'other-window) (define-key global-map (vector ?\s-&) #'delete-other-windows) (define-key global-map (vector ?\s-é) #'split-window-below) @@ -253,7 +327,10 @@ See `display-line-numbers' for details." ;; otherwise it would be interpreted as a string quote. (define-key global-map (vector 8388642) #'split-window-right) (define-key global-map (vector ?\s-à) #'delete-window) -(define-key global-map (vector ?\C-+) #'enlarge-window) +(define-key global-map (vector ?\C-+) #'durand-enlarge-window) +(define-key global-map (vector ?\C-=) #'durand-shrink-window) +(define-key global-map (vector ?\C-x ?\{) #'durand-shrink-window-horizontally) +(define-key global-map (vector ?\C-x ?\}) #'durand-enlarge-window-horizontally) (define-key global-map (vector ?\s-f) #'find-file) (define-key global-map (vector ?\s-F) #'find-file-other-window) (define-key global-map (vector ?\s-d) #'dired) -- cgit v1.2.3-18-g5258