From 0eee4defb09d895b1059eac98f64225f841007ac Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sat, 29 Jan 2022 13:16:59 +0000 Subject: emacs: Do a better job at disabling unwanted modes --- emacs/early-init.el | 5 ----- emacs/functions.el | 5 +++++ emacs/init.el | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/emacs/early-init.el b/emacs/early-init.el index 4080f10..a83816f 100644 --- a/emacs/early-init.el +++ b/emacs/early-init.el @@ -21,11 +21,6 @@ directories." (top . 0.3) (width . 160)) gc-cons-threshold (* 50 1024 1024)) -(menu-bar-mode -1) -;; Those functions may not exist if the GUI is not compiled in. -(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) -(if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) - ;; Further Early Customization diff --git a/emacs/functions.el b/emacs/functions.el index b322af6..37686b3 100644 --- a/emacs/functions.el +++ b/emacs/functions.el @@ -62,6 +62,11 @@ returns nil." (interactive) (modify-frame-parameters frame '((left . 0.5) (top . 0.5)))) +(defun my/disable-frame-modes () + "Disable select frame modes where appropriate." + (dolist (mode '(menu-bar-mode scroll-bar-mode tool-bar-mode)) + (when (and (fboundp mode) (symbol-value mode)) (funcall mode -1)))) + (defun my/focus-frame (&optional frame) "Focus FRAME." (interactive) diff --git a/emacs/init.el b/emacs/init.el index 30140ce..bdab985 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -43,9 +43,6 @@ (add-hook 'after-init-hook #'my/display-startup-time) (add-hook 'before-save-hook #'delete-trailing-whitespace) -(my/with-add-hook 'server-switch-hook - (menu-bar-mode -1) - (scroll-bar-mode -1)) (auto-save-mode -1) (auto-save-visited-mode 1) @@ -124,6 +121,9 @@ (dolist (fn '(delete-window split-window-horizontally split-window-vertically)) (advice-add fn :after #'(lambda (&rest _args) (balance-windows)))) +(if (daemonp) (add-hook 'before-make-frame-hook #'my/disable-frame-modes) + (my/disable-frame-modes)) + ;; Bazel -- cgit v1.2.3-70-g09d2