about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-01-02 17:35:33 -0600
committerCase Duckworth2021-01-02 17:35:33 -0600
commit48928e6c8350a699e9572c2632f049c4b0aeddbf (patch)
tree37fd7d8402d8a7ec747b26db582f835921de35aa
parentMove header-args to begin_src lines for *init.el (diff)
downloademacs-48928e6c8350a699e9572c2632f049c4b0aeddbf.tar.gz
emacs-48928e6c8350a699e9572c2632f049c4b0aeddbf.zip
Add acdw/when-unfocused
Runs a command only if Emacs’ frames are unfocused.  Should be run in a
after-focus-change-hook.  I should probably make a macro or something to really
friendlify it.
-rw-r--r--config.org13
1 files changed, 12 insertions, 1 deletions
diff --git a/config.org b/config.org index d45c46e..4bd98cd 100644 --- a/config.org +++ b/config.org
@@ -89,7 +89,7 @@ doesn't work, I'll call git directly and clone the repo myself.
89 (acdw/bootstrap-straight)) 89 (acdw/bootstrap-straight))
90#+END_SRC 90#+END_SRC
91 91
92** Customize macros 92** Ease-of-configuring functions
93 93
94*** Emulate use-package’s =:custom= 94*** Emulate use-package’s =:custom=
95 95
@@ -120,6 +120,17 @@ doesn't work, I'll call git directly and clone the repo myself.
120 (add-hook 'after-init-hook #'acdw/set-custom-faces)) 120 (add-hook 'after-init-hook #'acdw/set-custom-faces))
121#+end_src 121#+end_src
122 122
123*** Determine whether any Emacs frame is focused or not
124
125This comes in handy when I want to garbage collect, say, or save recent files.
126
127 #+begin_src emacs-lisp
128 (defun acdw/when-unfocused (func &rest args)
129 "Run FUNC with ARGS only if all frames are out of focus."
130 (if (seq-every-p #'null (mapcar #'frame-focus-state (frame-list)))
131 (apply func args)))
132 #+end_src
133
123** Clean =.emacs.d= 134** Clean =.emacs.d=
124 135
125#+BEGIN_SRC emacs-lisp 136#+BEGIN_SRC emacs-lisp