Bunch of changes
This commit is contained in:
@@ -39,24 +39,23 @@
|
||||
"Minimum size of padding string.")
|
||||
|
||||
(defun bml/--get-padding-size (other-size)
|
||||
"Compute length of padding to ensure string of size OTHER is on an
|
||||
"Compute length of padding to ensure string of size OTHER-SIZE is on an
|
||||
extreme end to CENTRE-SEGMENT."
|
||||
(let* ((centre-size (length (format-mode-line bml/centre-segment)))
|
||||
(win-width (window-width))
|
||||
(margins (window-margins))
|
||||
(width (if (null (car margins))
|
||||
win-width
|
||||
(+ (car margins) win-width (cdr margins)))))
|
||||
(floor (- (/ width 2) (/ centre-size 2) other-size))))
|
||||
(let ((centre-size (length (format-mode-line bml/centre-segment)))
|
||||
(window-width ;; compute total width of window (including margins)
|
||||
(thread-last (cons (window-width) (window-margins))
|
||||
(mapcar (lambda (x) (if (null x) 0 x)))
|
||||
(cl-reduce #'+))))
|
||||
(floor (- (/ window-width 2) (/ centre-size 2) other-size))))
|
||||
|
||||
(defun bml/--generate-padding (segment)
|
||||
"Make padding string to separate center segment from SEGMENT."
|
||||
(let* ((segment-size (length (format-mode-line segment)))
|
||||
(padding-size (bml/--get-padding-size segment-size)))
|
||||
(make-string (min padding-size bml/--minimum-padding) ?\s)))
|
||||
(make-string (max padding-size bml/--minimum-padding) ?\s)))
|
||||
|
||||
(defun bml/setup-mode-line ()
|
||||
"Call this to setup the mode-line when:
|
||||
"Call this to setup the mode-line when either:
|
||||
- first loading the package.
|
||||
- segments are updated."
|
||||
(setq-default mode-line-format
|
||||
|
||||
@@ -53,16 +53,29 @@
|
||||
(find-file name))))
|
||||
|
||||
(defun eshell/project-root (&rest args)
|
||||
"Change to directory `project-root'"
|
||||
(cond
|
||||
((project-current)
|
||||
(eshell-goto-latest-prompt)
|
||||
(eshell/cd (list (project-root (project-current)))))
|
||||
(t
|
||||
(setq eshell-last-command-status 1)
|
||||
(eshell/echo
|
||||
(format "[%s]: No project in current directory"
|
||||
(propertize "Error" 'font-lock-face '(:foreground "red")))))))
|
||||
"Change to directory of `project-root', if current working directory is
|
||||
in a project."
|
||||
(eshell-eval-using-options
|
||||
"project-root"
|
||||
args
|
||||
'((?h "help" nil nil "show usage")
|
||||
:usage "
|
||||
|
||||
Go to the root of the project which the current working directory is a
|
||||
member of. If the current working directory is not in a valid project,
|
||||
an error is produced.")
|
||||
(cond
|
||||
((project-current)
|
||||
(eshell-goto-latest-prompt)
|
||||
(thread-last (project-current)
|
||||
(project-root)
|
||||
(list)
|
||||
(eshell/cd)))
|
||||
(t
|
||||
(setq eshell-last-command-status 1)
|
||||
(thread-last (propertize "Error" 'font-lock-face '(:foreground "red"))
|
||||
(format "[%s]: No project in current directory")
|
||||
(eshell/echo))))))
|
||||
|
||||
(defun eshell/sudo-switch (&rest args)
|
||||
"Switch to and from administrative (sudo) mode in Eshell.
|
||||
|
||||
Reference in New Issue
Block a user