Add variable to enable tool bar, menu bar, tool tips, and context menu.

This commit is contained in:
James Cherti
2024-08-19 09:55:01 -04:00
parent bca3c8df6a
commit 84ef25a9a3
3 changed files with 72 additions and 26 deletions

View File

@@ -135,6 +135,29 @@ To prevent Emacs from saving customization information to a custom file, set `cu
(setq custom-file null-device)
```
### How to enable dialogs, context menu, tool-bar, menu-bar, and tooltips?
To customize your Emacs setup to include various user interface elements, you can use the following settings in your ``~/.emacs.d/pre-early-init.el``:
``` emacs-lisp
;; Enable both file dialogs and dialog boxes
(setq minimal-emacs-disable-dialogs nil)
;; Enable context menu (right-click menu)
(setq minimal-emacs-disable-context-menu nil)
;; Enable the tool bar at the top
(setq minimal-emacs-disable-tool-bar nil)
;; Enable the menu bar at the top
(setq minimal-emacs-disable-menu-bar nil)
;; Enable tooltips (hover text)
(setq minimal-emacs-disable-tooltips nil)
```
These settings control the visibility of dialogs, context menus, toolbars, menu bars, and tooltips.
### How to activate recentf, savehist, saveplace, and auto-revert?
The recentf, savehist, saveplace, and auto-revert built-in packages are already configured by `minimal-emacs.d`. All you need to do is activate them by adding the following to `~/.emacs.d/post-init.el`:
@@ -491,18 +514,18 @@ Here is an example of how to configure Eglot to enable or disable certain option
``` emacs-lisp
(setq-default eglot-workspace-configuration
`(:pylsp (:plugins
(; Fix imports and syntax
(;; Fix imports and syntax using `eglot-format-buffer`
:isort (:enabled t)
:autopep8 (:enabled t)
;; Syntax checkers (work with flymake)
;; Syntax checkers (works with Flymake)
:pylint (:enabled t)
:pycodestyle (:enabled t)
:flake8 (:enabled t)
:pyflakes (:enabled t)
:pydocstyle (:enabled t)
:mccabe (:enabled t)
:yapf (:enabled :json-false)
:rope_autoimport (:enabled :json-false)))))
@@ -586,10 +609,6 @@ Add the following to `~/.emacs.d/post-init.el`:
:config
(which-key-mode))
;; Add context menu
(when (display-graphic-p)
(context-menu-mode))
(pixel-scroll-precision-mode)
(display-time-mode)
@@ -606,7 +625,6 @@ Add the following to `~/.emacs.d/pre-early-init.el` to ensure that `minimal-emac
### How to change the outline-mode or outline-minor-mode Ellipsis (...) to (▼)?
If you want to to change the outline-mode or outline-minor-mode Ellipsis (...) to (▼), use the code snippet in this article: [Changing the Ellipsis (“…”) in outline-mode and outline-minor-mode](https://www.jamescherti.com/emacs-customize-ellipsis-outline-minor-mode/).
### How to run the minimal-emacs.d Emacs configuration from another directory?

View File

@@ -49,6 +49,21 @@
(defvar minimal-emacs--default-mode-line-format mode-line-format
"Default value of `mode-line-format'.")
(defvar minimal-emacs-disable-context-menu t
"Non-nil enables the context menu in graphical environments.")
(defvar minimal-emacs-disable-tool-bar t
"Non-nil enables the tool bar in graphical environments.")
(defvar minimal-emacs-disable-menu-bar t
"Non-nil enables the tool bar in graphical environments.")
(defvar minimal-emacs-disable-dialogs t
"If non-nil, enable both file dialogs and dialog boxes.")
(defvar minimal-emacs-disable-tooltips t
"When non-nil, tooltips are enabled. If nil, tooltips are disabled.")
;;; Misc
(set-language-environment "UTF-8")
@@ -215,29 +230,31 @@
;; a superfluous and potentially expensive frame redraw at startup, depending
;; on the window system. The variables must also be set to `nil' so users don't
;; have to call the functions twice to re-enable them.
(when minimal-emacs-disable-menu-bar
(push '(menu-bar-lines . 0) default-frame-alist)
(unless (memq window-system '(mac ns))
(setq menu-bar-mode nil)))
(when minimal-emacs-disable-tool-bar
(push '(tool-bar-lines . 0) default-frame-alist)
(setq tool-bar-mode nil))
(push '(vertical-scroll-bars) default-frame-alist)
(push '(horizontal-scroll-bars) default-frame-alist)
(setq tool-bar-mode nil
scroll-bar-mode nil)
(when (bound-and-true-p tooltip-mode)
(tooltip-mode -1))
;; Disable GUIs because theyr are inconsistent across systems, desktop
;; environments, and themes, and they don't match the look of Emacs.
(setq use-file-dialog nil)
(setq use-dialog-box nil)
(unless (memq window-system '(mac ns))
;; (menu-bar-mode -1)
(setq menu-bar-mode nil))
(setq scroll-bar-mode nil)
(when (fboundp 'horizontal-scroll-bar-mode)
(horizontal-scroll-bar-mode -1))
(when minimal-emacs-disable-tooltips
(when (bound-and-true-p tooltip-mode)
(tooltip-mode -1)))
;; Disable GUIs because they are inconsistent across systems, desktop
;; environments, and themes, and they don't match the look of Emacs.
(when minimal-emacs-disable-dialogs
(setq use-file-dialog nil)
(setq use-dialog-box nil))
;; Allow for shorter responses: "y" for yes and "n" for no.
(if (boundp 'use-short-answers)
(setq use-short-answers t)

11
init.el
View File

@@ -215,6 +215,12 @@
;; which should quickly self-correct.
(setq fast-but-imprecise-scrolling t)
;;; Mouse
;; Emacs 29
(when (and (display-graphic-p) (fboundp 'context-menu-mode))
(add-hook 'after-init-hook #'context-menu-mode))
(setq hscroll-margin 2
hscroll-step 1
;; Emacs spends excessive time recentering the screen when the cursor
@@ -327,6 +333,11 @@
(setq line-number-mode t)
(setq column-number-mode t)
;;; Filetype
;; Do not notify the user each time Python tries to guess the indentation offset
(setq python-indent-guess-indent-offset-verbose nil)
;;; Load post-init.el
(minimal-emacs-load-user-init "post-init.el")