‘C-h’ or <F1> mean “help” in various other contexts as well. For instance, you can type them after a prefix key to view a list of the keys that can follow the prefix key.
Meaning it shows up in a new buffer that IIRC isn’t interactive
With consult and marginalia installed, it transforms that buffer into a selection list (wrong word, FIXME) that lets you take the action you wanted and learn the necessary information all at once.
C-g (or ctrl+g) is the universal way to exit prompts and kill processes in emacs (like your computers ESC key)
List all possible project based commands and optionally select one or C-g out of consult window/prompt
link broken or works fine in no org-roam repo with questionable submodules that probably need ignored?
This will open any page in your default browser. Typically search results are fine and most pages from the search results are fine in the text browser. For the times they aren’t though, this will fix it.
NOTE
after using a project command from within a docker container, devcontainer, or really any tramp#Inline methods that project will be accessible using C-x p p (aka. M-x project-switch-project)
tramp#Remote programs
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
It’s what you may call a “window”. There can be multiple split windows or “buffers” in emacs.
It’s worth getting used to what emacs calls each of these things though to better understand tutorials, documentation, and accurately ask others for help.
If you go on to extend emacs with elisp, it becomes even more valuable to know these concepts.
The below example may be enough to form a good understanding of frames, buffers, and windows:
- frames contain a set of windows and are what you might call the “window” in your OS
- windows can contain buffers
- buffers can contain anything and may or not represent files saved to disk
See related documentation:
- emacs#Buffers
- emacs#Windows
- emacs#Frames
still feel unsure? Create a new scratch buffer or file with org-mode
activated and try experimenting!
add Melpa to package-sources
So we can install packages you see listed and can search on https://melpa.org
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(defvar menuitem3
'("Appearance"
["Change theme" (call-interactively 'consult-theme)]
;; ("SubSubmenu"
;; ["This will do wonders" (lambda () (interactive) (beep)) [:help "Welcome to the banana"]]
;; ["And this will do nothing" (lambda () (interactive))])
;; ("SubSubmenu2"
;; ["Boring alias" (replace-string " " " banana ")])
)
)
(defvar menuitem4
'("Roam"
["Today" (call-interactively 'org-roam-dailies-find-today)]
["Yesterday" (call-interactively 'org-roam-dailies-find-yesterday)]
["Find/Create node" (call-interactively 'org-roam-node-find)]
["Insert link to node" (call-interactively 'org-roam-node-insert)]
["--" 'ignore]
["Random node" (call-interactively 'org-roam-node-random)]
["Go to date" (call-interactively 'org-roam-dailies-find-today)]
)
)
(easy-menu-define test-menu nil "Menu used as an example."
`("Test menu"
,menuitem3
,menuitem4
;; ["Items can also be defined here" (lambda () (interactive) (message-box "It's simple!"))]
)
)
(define-key-after (lookup-key global-map [menu-bar])
[mymenu] ; shortcut for our menu
(cons "Discoverable Emacs" test-menu) 'options)
(use-package alert
:ensure t
:config
<<alert-config>>
)
(defun core/emacs-tangle-and-show-alert-with-cpu-time ()
(interactive)
(let ((gc-cons-threshold most-positive-fixnum))
(alert (format "Tangling emacs took: %.3fs"
(caaddr (core/bench 1
(org-babel-tangle)))))))
;;;###autoload
(cl-defmacro core/bench (&optional (times 100000) &rest body)
"Call `benchmark-run-compiled' on BODY with TIMES iterations, returning list suitable for Org source block evaluation.
Garbage is collected before calling `benchmark-run-compiled' to
avoid counting existing garbage which needs collection."
(declare (indent defun))
`(progn
(garbage-collect)
(list '("Total runtime" "# of GCs" "Total GC runtime")
'hline
(benchmark-run-compiled ,times
(progn
,@body)))))
(setq use-package-always-ensure t)
(setq ring-bell-function 'ignore)
(defalias 'yes-or-no-p 'y-or-n-p)
NOTE theme is loaded in init.el, then user can select a theme. To persist it use load-theme like below and if needed use-package
to install the theme(s) first.
(use-package doom-themes)
;; (load-theme 'doom-one t)
;; (load-theme 'modus-vivendi t)
(tool-bar-mode 0)
(menu-bar-mode 1)
(custom-set-faces '(default ((t (:family "Roboto Mono" :height 160))))
'(fixed-pitch ((t (:family "Roboto Mono" :height 160))))
'(variable-pitch ((t (:family "Lato" :height 170)))))
(setq-default line-spacing nil)
;; default
(dolist (face '(default fixed-pitch))
(set-face-attribute `,face nil :family "Roboto Mono" :height 160))
alert is used in core functions and is a special case that must be loaded before those core functions here
(setq alert-default-style 'libnotify)
(use-package emacs
:bind
<<emacs-keybinds>>
:config
<<emacs-config>>
)
(setq ediff-window-setup-function 'ediff-setup-windows-plain)
("C-x C-b" . 'ibuffer)
(setq bookmark-save-flag 1)
(pixel-scroll-precision-mode 1)
(use-package org
:ensure nil
:hook
(org-mode . my/org-mode-setup)
:config
(setq org-ellipsis " ▾")
(setq org-cycle-separator-lines -1)
(setq org-return-follows-link t)
(defun set-fixed-pitch-org-attributes ()
;; Make sure org-indent face is available
(require 'org-indent)
;; ;; Ensure that anything that should be fixed-pitch in Org files appears that way
(set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-table nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-indent nil :inherit '(org-hide fixed-pitch))
(set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch))
(defun my/org-mode-setup ()
;; TODO not 100% this is working, lol
(org-indent-mode 1)
(variable-pitch-mode 1)
(set-fixed-pitch-org-attributes)
)
)
(use-package ob
:ensure nil
:config
(setq org-confirm-babel-evaluate nil)
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(shell . t)
(haskell . t)
)))
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook))
(use-package org-modern)
(setq alert-default-style 'libnotify)
(use-package vertico
:init
<<vertico-config>>
)
(require 'vertico)
(vertico-mode)
(use-package no-littering)
(use-package consult
<<unliterate-consult-use-package-body>>
)
:bind (;; C-c bindings (mode-specific-map)
("C-c h" . consult-history)
("C-c m" . consult-mode-command)
("C-c k" . consult-kmacro)
;; C-x bindings (ctl-x-map)
("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command
("C-x b" . consult-buffer) ;; orig. switch-to-buffer
("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window
("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame
("C-x r b" . consult-bookmark) ;; orig. bookmark-jump
("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer
;; Custom M-# bindings for fast register access
("M-#" . consult-register-load)
("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated)
("C-M-#" . consult-register)
;; Other custom bindings
("M-y" . consult-yank-pop) ;; orig. yank-pop
;; M-g bindings (goto-map)
("M-g e" . consult-compile-error)
("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
("M-g g" . consult-goto-line) ;; orig. goto-line
("M-g M-g" . consult-goto-line) ;; orig. goto-line
("M-g o" . consult-outline) ;; Alternative: consult-org-heading
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
;; M-s bindings (search-map)
("M-s d" . consult-find)
("M-s D" . consult-locate)
("M-s g" . consult-grep)
("M-s G" . consult-git-grep)
("M-s r" . consult-ripgrep)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
("M-s k" . consult-keep-lines)
("M-s u" . consult-focus-lines)
;; Isearch integration
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
("M-s l" . consult-line) ;; needed by consult-line to detect isearch
("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
;; Minibuffer history
:map minibuffer-local-map
("M-s" . consult-history) ;; orig. next-matching-history-element
("M-r" . consult-history)) ;; orig. previous-matching-history-element
;; Enable automatic preview at point in the *Completions* buffer. This is
;; relevant when you use the default completion UI.
:hook (completion-list-mode . consult-preview-at-point-mode)
;; The :init configuration is always executed (Not lazy)
:init
;; Optionally configure the register formatting. This improves the register
;; preview for `consult-register', `consult-register-load',
;; `consult-register-store' and the Emacs built-ins.
(setq register-preview-delay 0.5
register-preview-function #'consult-register-format)
;; Optionally tweak the register preview window.
;; This adds thin lines, sorting and hides the mode line of the window.
(advice-add #'register-preview :override #'consult-register-window)
;; Use Consult to select xref locations with preview
;; TODO fix
;; ⛔ Error (use-package): consult/:config: consult-xref is neither a Consult command nor a Consult source
;; (setq xref-show-xrefs-function #'consult-xref
;; xref-show-definitions-function #'consult-xref)
;; Configure other variables and modes in the :config section,
;; after lazily loading the package.
:config
;; Optionally configure preview. The default value
;; is 'any, such that any key triggers the preview.
;; (setq consult-preview-key 'any)
;; (setq consult-preview-key (kbd "M-."))
;; (setq consult-preview-key (list (kbd "<S-down>") (kbd "<S-up>")))
;; For some commands and buffer sources it is useful to configure the
;; :preview-key on a per-command basis using the `consult-customize' macro.
;; TODO consult-customize out of date now? see error:
;; corfu/:config: Symbol’s function definition is void: consult-customize
;; (consult-customize
;; consult-theme :preview-key '(:debounce 0.2 any)
;; consult-ripgrep consult-git-grep consult-grep
;; consult-bookmark consult-recent-file ;; consult-xref ;; TODO relaed to consult-xref error above
;; consult--source-bookmark consult--source-file-register
;; consult--source-recent-file consult--source-project-recent-file
;; ;; :preview-key (kbd "M-.")
;; :preview-key '(:debounce 0.4 any))
;; Optionally configure the narrowing key.
;; Both < and C-+ work reasonably well.
(setq consult-narrow-key "<") ;; (kbd "C-+")
;; Optionally make narrowing help available in the minibuffer.
;; You may want to use `embark-prefix-help-command' or which-key instead.
;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
;; By default `consult-project-function' uses `project-root' from project.el.
;; Optionally configure a different project root function.
;; There are multiple reasonable alternatives to chose from.
;;;; 1. project.el (the default)
;; (setq consult-project-function #'consult--default-project--function)
;;;; 2. projectile.el (projectile-project-root)
;; (autoload 'projectile-project-root "projectile")
;; (setq consult-project-function (lambda (_) (projectile-project-root)))
;;;; 3. vc.el (vc-root-dir)
;; (setq consult-project-function (lambda (_) (vc-root-dir)))
;;;; 4. locate-dominating-file
;; (setq consult-project-function (lambda (_) (locate-dominating-file "." ".git")))
;; Enable rich annotations using the Marginalia package
(use-package marginalia
;; Either bind `marginalia-cycle' globally or only in the minibuffer
:bind (("M-A" . marginalia-cycle)
:map minibuffer-local-map
("M-A" . marginalia-cycle))
;; The :init configuration is always executed (Not lazy!)
:init
;; Must be in the :init section of use-package such that the mode gets
;; enabled right away. Note that this forces loading the package.
(require 'marginalia)
(marginalia-mode))
(use-package orderless
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
(use-package beacon
:config
(beacon-mode 1))
(use-package doom-modeline
:hook (after-init . doom-modeline-mode))
(use-package all-the-icons)
(use-package dired
:ensure nil
:hook (
<<dired-hook>>
)
)
(dired-mode . dired-hide-details-mode)
(use-package org-roam
:hook
(after-init . org-roam-mode)
:config
<<org-roam-config>>
:bind
(
<<org-roam-bind>>
)
)
(use-package org-roam-dailies :ensure nil) ;; bundled now?? TODO figure out
(use-package org-roam-ui)
("C-c r t" . ' org-roam-dailies-find-today)
("C-c r y" . ' org-roam-dailies-find-yesterday)
("C-c r f" . ' org-roam-node-find)
("C-c r i" . ' org-roam-node-insert)
("C-c r r" . ' org-roam-node-random)
(setq org-roam-completion-everywhere t)
because hooks aren’t added to find-file here
(org-roam-db-autosync-mode)
(use-package winner
:ensure nil
:config
(winner-mode 1))
(use-package tramp
:ensure nil
:config
<<tramp-config>>
)
(use-package savehist
:config
(setq history-length 10000
history-delete-duplicates t
savehist-save-minibuffer-history t
savehist-additional-variables '(kill-ring
search-ring
<<savehist-additional-variable>>
regexp-search-ring))
(savehist-mode))
(use-package eww
:config
<<eww-config>>
)
(setq eww-history-limit 10000)
eww-history
(setq eww-auto-rename-buffer t)
(save-place-mode 1)
(recentf-mode 1)
(use-package olivetti
:after org
:config
(setq-default olivetti-body-width 80)
(setq-default olivetti-minimum-body-width 65)
:hook
(org-mode . olivetti-mode))
;; (require 'corfu) ;; TODO Remove This HACK because I don't know how to use an autoload in a custom emacs lisp package in nix
(use-package corfu
;; Optional customizations
:custom
;; (corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
;; I changed auto to nil because I think completion should be done on purpose
;; you can do it with M-TAB by default
(corfu-auto nil)
;; (corfu-commit-predicate nil) ;; Do not commit selected candidates on next input
(corfu-quit-at-boundary nil) ;; Automatically quit at word boundary
(corfu-quit-no-match t) ;; Automatically quit if there is no match
;; (corfu-echo-documentation nil) ;; Do not show documentation in the echo area
;; You may want to enable Corfu only for certain modes.
;; :hook ((prog-mode . corfu-mode)
;; (shell-mode . corfu-mode)
;; (eshell-mode . corfu-mode))
;; Recommended: Enable Corfu globally.
;; This is recommended since dabbrev can be used globally (M-/).
:config
(defun corfu-enable-always-in-minibuffer ()
"Enable Corfu in the minibuffer if Vertico/Mct are not active."
(unless (or (bound-and-true-p mct--active)
(bound-and-true-p vertico--input))
(setq-local corfu-auto t) ;; enable corfu-auto in minibuffer
(corfu-mode 1)))
(add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1)
;; TODO consult-customize out of date now? see error:
;; corfu/:config: Symbol’s function definition is void: consult-customize
;; (consult-customize
;; consult-theme
;; :preview-key '(:debounce 0.2 any)
;; consult-ripgrep consult-git-grep consult-grep
;; consult-bookmark consult-recent-file ;; consult-xref ;; TODO xref get deleted?
;; consult--source-bookmark consult--source-recent-file
;; consult--source-project-recent-file
;; :preview-key (kbd "M-."))
(setq consult-narrow-key "<") ;; (kbd "C-+")
(global-corfu-mode))
(use-package embark
:bind
(("C-." . embark-act) ;; pick some comfortable binding
("C-;" . embark-dwim) ;; good alternative: M-.
("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'
:config
:init
;; Optionally replace the key help with a completing-read interface
(setq prefix-help-command #'embark-prefix-help-command)
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
;; Consult users will also want the embark-consult package.
(use-package embark-consult
:after (embark consult)
:demand t ; only necessary if you have the hook below
;; if you want to have consult previews as you move around an
;; auto-updating embark collect buffer
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-package keycast
:config
(define-minor-mode keycast-mode
"Show current command and its key binding in the mode line (fix for use with doom-mode-line)."
:global t
(if keycast-mode
(add-hook 'pre-command-hook 'keycast--update t)
(remove-hook 'pre-command-hook 'keycast--update)))
(add-to-list 'global-mode-string '("" keycast-mode-line)))
(use-package gif-screencast
;; NOTE requires the deps: imagemagick gifsicle scrot
;;:ensure-system-package (gifsicle
;; mogrify
;; imagemagick)
:init
(setq gif-screencast-screenshot-directory "~/downloads/screencasts/tmp")
(setq gif-screencast-output-directory "~/downloads/screencasts")
:bind
(([f11] . gif-screencast)
([f12] . gif-screencast-stop)))
(use-package nix-mode)
(use-package magit)
(use-package tabspaces
:hook (after-init . tabspaces-mode) ;; use this only if you want the minor-mode loaded at startup.
:commands (tabspaces-switch-or-create-workspace
tabspaces-open-or-create-project-and-workspace)
:custom
(tabspaces-use-filtered-buffers-as-default t)
(tabspaces-default-tab "Default")
(tabspaces-remove-to-default t)
(tabspaces-include-buffers '("*scratch*"))
;; sessions
(tabspaces-session t)
(tabspaces-session-auto-restore t))
;; Filter Buffers for Consult-Buffer
(with-eval-after-load 'consult
;; hide full buffer list (still available with "b" prefix)
(consult-customize consult--source-buffer :hidden t :default nil)
;; set consult-workspace buffer list
(defvar consult--source-workspace
(list :name "Workspace Buffers"
:narrow ?w
:history 'buffer-name-history
:category 'buffer
:state #'consult--buffer-state
:default t
:items (lambda () (consult--buffer-query
:predicate #'tabspaces--local-buffer-p
:sort 'visibility
:as #'buffer-name)))
"Set workspace buffer list for consult-buffer.")
(add-to-list 'consult-buffer-sources 'consult--source-workspace))
(use-package ob-mongo
:config
)
db.employees.count({country: "gb"});
(context-menu-mode 1)
for instance I think core/bench depends on lexical binding
Because using emacs -Q
the value user-init-file
is nil and I wanted to preserve testing eaisly with Emacs -Q
I had to change this:
# eval: (add-hook 'after-save-hook (lambda () (load-file user-init-file)) nil t)
to this:
# eval: (add-hook 'after-save-hook (lambda () (load-file (concat (locate-dominating-file buffer-file-name "discoverable-emacs.el") "discoverable-emacs.el") )) nil t)
set org-id-link-to-org-use-id
Local variable to work with emacs users that don’t default to that or someone using Emacs -Q
# org-id-link-to-org-use-id: create-if-interactive