Add more api demos (#1845)
* Added function Demos * Added use-package demos * Some corrections * Fix duplicated use-package! type
This commit is contained in:
parent
167ce4ca4d
commit
dea5d84069
4 changed files with 81 additions and 33 deletions
|
@ -419,18 +419,7 @@ Properties
|
||||||
:unless [CONDITION] [...]
|
:unless [CONDITION] [...]
|
||||||
|
|
||||||
Any of the above properties may be nested, so that they only apply to a
|
Any of the above properties may be nested, so that they only apply to a
|
||||||
certain group of keybinds.
|
certain group of keybinds."
|
||||||
|
|
||||||
Example
|
|
||||||
(map! :map magit-mode-map
|
|
||||||
:m \"C-r\" 'do-something ; C-r in motion state
|
|
||||||
:nv \"q\" 'magit-mode-quit-window ; q in normal+visual states
|
|
||||||
\"C-x C-r\" 'a-global-keybind
|
|
||||||
:g \"C-x C-r\" 'another-global-keybind ; same as above
|
|
||||||
|
|
||||||
(:when IS-MAC
|
|
||||||
:n \"M-s\" 'some-fn
|
|
||||||
:i \"M-o\" (lambda (interactive) (message \"Hi\"))))"
|
|
||||||
(doom--map-process rest))
|
(doom--map-process rest))
|
||||||
|
|
||||||
(provide 'core-keybinds)
|
(provide 'core-keybinds)
|
||||||
|
|
|
@ -301,10 +301,6 @@ If N and M = 1, there's no benefit to using this macro over `remove-hook'.
|
||||||
(defmacro setq-hook! (hooks &rest var-vals)
|
(defmacro setq-hook! (hooks &rest var-vals)
|
||||||
"Sets buffer-local variables on HOOKS.
|
"Sets buffer-local variables on HOOKS.
|
||||||
|
|
||||||
(setq-hook! 'markdown-mode-hook
|
|
||||||
line-spacing 2
|
|
||||||
fill-column 80)
|
|
||||||
|
|
||||||
\(fn HOOKS &rest [SYM VAL]...)"
|
\(fn HOOKS &rest [SYM VAL]...)"
|
||||||
(declare (indent 1))
|
(declare (indent 1))
|
||||||
(macroexp-progn
|
(macroexp-progn
|
||||||
|
|
|
@ -425,26 +425,17 @@ two extra properties:
|
||||||
:after-call SYMBOL|LIST
|
:after-call SYMBOL|LIST
|
||||||
Takes a symbol or list of symbols representing functions or hook variables.
|
Takes a symbol or list of symbols representing functions or hook variables.
|
||||||
The first time any of these functions or hooks are executed, the package is
|
The first time any of these functions or hooks are executed, the package is
|
||||||
loaded. e.g.
|
loaded.
|
||||||
|
|
||||||
(use-package! projectile
|
|
||||||
:after-call (pre-command-hook after-find-file dired-before-readin-hook)
|
|
||||||
...)
|
|
||||||
|
|
||||||
:defer-incrementally SYMBOL|LIST|t
|
:defer-incrementally SYMBOL|LIST|t
|
||||||
Takes a symbol or list of symbols representing packages that will be loaded
|
Takes a symbol or list of symbols representing packages that will be loaded
|
||||||
incrementally at startup before this one. This is helpful for large packages
|
incrementally at startup before this one. This is helpful for large packages
|
||||||
like magit or org, which load a lot of dependencies on first load. This lets
|
like magit or org, which load a lot of dependencies on first load. This lets
|
||||||
you load them piece-meal during idle periods, so that when you finally do need
|
you load them piece-meal during idle periods, so that when you finally do need
|
||||||
the package, it'll load quicker. e.g.
|
the package, it'll load quicker.
|
||||||
|
|
||||||
NAME is implicitly added if this property is present and non-nil. No need to
|
NAME is implicitly added if this property is present and non-nil. No need to
|
||||||
specify it. A value of `t' implies NAME, e.g.
|
specify it. A value of `t' implies NAME."
|
||||||
|
|
||||||
(use-package! abc
|
|
||||||
;; This is equivalent to :defer-incrementally (abc)
|
|
||||||
:defer-incrementally t
|
|
||||||
...)"
|
|
||||||
(declare (indent 1))
|
(declare (indent 1))
|
||||||
(unless (or (memq name doom-disabled-packages)
|
(unless (or (memq name doom-disabled-packages)
|
||||||
;; At compile-time, use-package will forcibly load packages to
|
;; At compile-time, use-package will forcibly load packages to
|
||||||
|
|
82
docs/api.org
82
docs/api.org
|
@ -27,6 +27,7 @@ It is integrated into Helpful, in Doom.
|
||||||
- [[#remove-hook][remove-hook!]]
|
- [[#remove-hook][remove-hook!]]
|
||||||
- [[#setq-hook][setq-hook!]]
|
- [[#setq-hook][setq-hook!]]
|
||||||
- [[#unsetq-hook][unsetq-hook!]]
|
- [[#unsetq-hook][unsetq-hook!]]
|
||||||
|
- [[#use-package][use-package!]]
|
||||||
- [[#interesting-snippets][Interesting snippets]]
|
- [[#interesting-snippets][Interesting snippets]]
|
||||||
- [[#persist-emacs-initial-frame-size-across-sessions][Persist Emacs' initial frame size across sessions]]
|
- [[#persist-emacs-initial-frame-size-across-sessions][Persist Emacs' initial frame size across sessions]]
|
||||||
- [[#persist-emacs-initial-frame-position-dimensions-andor-full-screen-state-across-sessions][Persist Emacs' initial frame position, dimensions and/or full-screen state across sessions]]
|
- [[#persist-emacs-initial-frame-position-dimensions-andor-full-screen-state-across-sessions][Persist Emacs' initial frame position, dimensions and/or full-screen state across sessions]]
|
||||||
|
@ -159,7 +160,12 @@ It is integrated into Helpful, in Doom.
|
||||||
|
|
||||||
*** TODO defer-feature!
|
*** TODO defer-feature!
|
||||||
*** TODO defer-until!
|
*** TODO defer-until!
|
||||||
*** TODO disable-packages!
|
*** disable-packages!
|
||||||
|
#+BEGIN_SRC elisp :eval no
|
||||||
|
;; Disable packages enabled by DOOM
|
||||||
|
(disable-packages! some-package second-package)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
*** doom!
|
*** doom!
|
||||||
#+BEGIN_SRC elisp :eval no
|
#+BEGIN_SRC elisp :eval no
|
||||||
(doom! :completion
|
(doom! :completion
|
||||||
|
@ -220,7 +226,31 @@ It is integrated into Helpful, in Doom.
|
||||||
(load! "~/.maynotexist" nil t)
|
(load! "~/.maynotexist" nil t)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** TODO map!
|
*** map!
|
||||||
|
#+BEGIN_SRC elisp :eval no
|
||||||
|
(map! :map magit-mode-map
|
||||||
|
:m "C-r" 'do-something ; C-r in motion state
|
||||||
|
:nv "q" 'magit-mode-quit-window ; q in normal+visual states
|
||||||
|
"C-x C-r" 'a-global-keybind
|
||||||
|
:g "C-x C-r" 'another-global-keybind ; same as above
|
||||||
|
|
||||||
|
(:when IS-MAC
|
||||||
|
:n "M-s" 'some-fn
|
||||||
|
:i "M-o" (lambda (interactive) (message "Hi"))))
|
||||||
|
|
||||||
|
(map! (:when (featurep! :completion company) ; Conditional loading
|
||||||
|
:i "C-@" #'+company/complete
|
||||||
|
(:prefix "C-x" ; Use a prefix key
|
||||||
|
:i "C-l" #'+company/whole-lines)))
|
||||||
|
|
||||||
|
(map! (:when (featurep! :lang latex) ; local conditional
|
||||||
|
(:map LaTeX-mode-map
|
||||||
|
:localleader ; Use local leader
|
||||||
|
:desc "View" "v" #'TeX-view)) ; Add which-key description
|
||||||
|
:leader ; Use leader key from now on
|
||||||
|
:desc "Eval expression" ";" #'eval-expression)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
*** package!
|
*** package!
|
||||||
#+BEGIN_SRC elisp :eval no
|
#+BEGIN_SRC elisp :eval no
|
||||||
;; To install a package that can be found on ELPA or any of the sources
|
;; To install a package that can be found on ELPA or any of the sources
|
||||||
|
@ -257,7 +287,11 @@ It is integrated into Helpful, in Doom.
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
*** TODO pushnew!
|
*** TODO pushnew!
|
||||||
*** TODO quiet!
|
*** quiet!
|
||||||
|
#+BEGIN_SRC elisp :eval no
|
||||||
|
;; Enters recentf-mode without extra output
|
||||||
|
(quiet! (recentf-mode +1))
|
||||||
|
#+END_SRC
|
||||||
*** remove-hook!
|
*** remove-hook!
|
||||||
#+BEGIN_SRC elisp :eval no
|
#+BEGIN_SRC elisp :eval no
|
||||||
;; With only one hook and one function, this is identical to `remove-hook'. In
|
;; With only one hook and one function, this is identical to `remove-hook'. In
|
||||||
|
@ -276,9 +310,47 @@ It is integrated into Helpful, in Doom.
|
||||||
;; Removing arbitrary forms (must be exactly the same as the definition)
|
;; Removing arbitrary forms (must be exactly the same as the definition)
|
||||||
(remove-hook! (one-mode second-mode) (setq v 5) (setq a 2))
|
(remove-hook! (one-mode second-mode) (setq v 5) (setq a 2))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** TODO setq-hook!
|
*** setq-hook!
|
||||||
*** TODO unsetq-hook!
|
#+BEGIN_SRC elisp :eval no
|
||||||
|
;; Set multiple variables after a hook
|
||||||
|
(setq-hook! 'markdown-mode-hook
|
||||||
|
line-spacing 2
|
||||||
|
fill-column 80)
|
||||||
|
|
||||||
|
;; Set variables after multiple hooks
|
||||||
|
(setq-hook! '(eshell-mode-hook term-mode-hook)
|
||||||
|
hscroll-margin 0)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
*** unsetq-hook!
|
||||||
|
#+BEGIN_SRC elisp :eval no
|
||||||
|
(unsetq-hook! 'markdown-mode-hook line-spacing)
|
||||||
|
|
||||||
|
;; Removes the following variable hook
|
||||||
|
(setq-hook! 'markdown-mode-hook line-spacing 2)
|
||||||
|
|
||||||
|
;; Removing N variables from M hooks
|
||||||
|
(unsetq-hook! some-mode enable-something and-another)
|
||||||
|
(unsetq-hook! some-mode (enable-something and-another))
|
||||||
|
(unsetq-hook! '(one-mode-hook second-mode-hook) enable-something)
|
||||||
|
(unsetq-hook! (one-mode second-mode) enable-something)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
*** use-package!
|
||||||
|
#+BEGIN_SRC elisp :eval no
|
||||||
|
;; Use after-call to load package before hook
|
||||||
|
(use-package! projectile
|
||||||
|
:after-call (pre-command-hook after-find-file dired-before-readin-hook))
|
||||||
|
|
||||||
|
;; defer recentf packages one by one
|
||||||
|
(use-package! recentf
|
||||||
|
:defer-incrementally easymenu tree-widget timer
|
||||||
|
:after-call after-find-file)
|
||||||
|
|
||||||
|
;; This is equivalent to :defer-incrementally (abc)
|
||||||
|
(use-package! abc
|
||||||
|
:defer-incrementally t)
|
||||||
|
#+END_SRC
|
||||||
* Interesting snippets
|
* Interesting snippets
|
||||||
** Persist Emacs' initial frame size across sessions
|
** Persist Emacs' initial frame size across sessions
|
||||||
#+BEGIN_SRC elisp
|
#+BEGIN_SRC elisp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue