Преглед на файлове

Merge changes form work.

Eiyeron Fulmincendii преди 5 години
родител
ревизия
3d35cfaf47
променени са 2 файла, в които са добавени 212 реда и са изтрити 59 реда
  1. 212 51
      config.org
  2. 0 8
      packages.el

+ 212 - 51
config.org

@@ -1,5 +1,4 @@
 #+TITLE:Doomed Chicken
-
 * Preface
 This is another attempt at making a decent Emacs configuration for the chicken I
 am. Having multiple files with a poor consistence or a directed goal always bit
@@ -20,7 +19,7 @@ around this list:
 - and of course, emacs-lisp
 * TODO Packages
 :PROPERTIES:
-:header-args:elisp: :tangle packages.el
+:header-args:emacs-lisp: :tangle packages.el
 :END:
 I heard I could manage my ~packages.el~ file directly from here. So why not
 doing it?
@@ -29,7 +28,7 @@ First, the header so Doom shouldn't byte-compile this file. It'd make the
 updates harder due to requiring a manual ~doom build~ invocation for every
 change done. I'm directly stealing it from the example provided by Doom Emacs.
 
-#+begin_src elisp
+#+begin_src emacs-lisp
 ;; -*- no-byte-compile: t; -*-
 ;;; .doom.d/packages.el
 #+end_src
@@ -38,20 +37,31 @@ change done. I'm directly stealing it from the example provided by Doom Emacs.
 It's rather solid for a terminal emulator. Too bad it doesn't seem to work on
 Windows. (Actually I haven't tried so hard, I just don't always have the time to
 find a way to compile it)
-#+begin_src elisp
+#+begin_src emacs-lisp
 (package! vterm :ignore (eq system-type 'windows-nt))
 #+end_src
 *** Graphviz
 Making graphs is fun
-#+begin_src elisp
+#+begin_src emacs-lisp
 (package! graphviz-dot-mode)
 #+end_src
 *** Python pacakges
 Python X allows me to have a notebook-ish workflow. More about this in its
 configuration section
-#+begin_src elisp
+#+begin_src emacs-lisp
 (package! python-x)
 #+end_src
+*** Ob-async
+Not having emacs be stuck when doing heavier stuff seems great. Let's use that.
+#+begin_src emacs-lisp
+(package! ob-async)
+#+end_src
+*** TODO The rest of the owl
+#+begin_src emacs-lisp
+(package! ascii-art-to-unicode)
+(package! mixed-pitch)
+#+end_src
+* TODO Buffer-local variables to make stuff easily tweakable
 * Helper functions
 I had issues before dealing with specific patterns at configuration time. At
 this moment, I don't have all the packages nor do I want to deal with them
@@ -59,13 +69,34 @@ manually. So I'm reinventing the wheel at some places to make the configuration
 easier to use.
 ** A filter function
 I haven't found one bundled with emacs yet. I'm using a homebrew filter function
-directly taken from a cookbook page [[https://www.emacswiki.org/emacs/ElispCookbook#toc39][here]] so I can skip requiring ~cl~ or ~seq~
+directly taken from a cookbook page [[https://www.emacswiki.org/emacs/Emacs-LispCookbook#toc39][here]] so I can skip requiring ~cl~ or ~seq~
 at launch.
-#+begin_src elisp
+#+begin_src emacs-lisp
 (defun chicken/filter (condp lst)
   (delq nil
         (mapcar (lambda (x) (and (funcall condp x) x)) lst)))
 #+end_src
+** TODO Detect Dark Mode
+Because why not? I'm planning to use that around launch to toggle between two themes but I worry about the actual boot time impact.
+#+begin_src emacs-lisp
+(defun chicken/uses-dark-mode-p()
+  (let ((windows-get-mode-command "powershell \"Get-ItemPropertyValue -Path HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize -Name SystemUsesLightTheme\""))
+    (cond
+     ((eq system-type 'windows-nt)
+      (string= "0\n" (shell-command-to-string windows-get-mode-command)))
+     (t (message "Ok")))))
+#+end_src
+** Measure time of a function call
+Based on a code found [[https://lists.gnu.org/archive/html/help-gnu-emacs/2008-06/msg00087.html][here]]. It's not really used here yet, but it could be
+useful to diagnose long configuration setting in my configuration.
+#+begin_src emacs-lisp
+(defmacro chicken/measure-time-m (&rest body)
+  "Measure the time it takes to evaluate BODY."
+  `(let ((time (current-time)))
+     ,@body
+     (message "%.06f" (float-time (time-since time)))))
+#+end_src
+
 * Look and Feel
 ** The colors
 Lately, I have been partial towards Gruvbox, for multiple reasons, the first
@@ -75,6 +106,14 @@ based on Gruvbox. Good thing Doom Emacs has a preset for this specific
 colorscheme.
 #+BEGIN_SRC emacs-lisp
 (setq doom-theme 'doom-gruvbox)
+
+(add-to-list 'custom-safe-themes
+             ;; Gruvbox-light
+             "ff984792cce90b274d29d59e63c8a51ce91ff0ab01d6504f7d407ef545aa1a82"
+             ;; Gruvbox-dark
+             "8141c11fa933b60d4ae77bd74187d7ff8a510c3237515a68c79cf997277bd3b4"
+             )
+
 #+END_SRC
 ** The fonts
 The other basic configuration I usually do first too is setting a font.
@@ -88,20 +127,28 @@ mighty ligatures.
 On the other hand, I don't always want to install all the fonts everywhere, so
 let's build first a font selector so I can gracefully fallback on other fonts
 when needed.
-
 #+begin_src emacs-lisp
 (defun chicken/select-first-available-font (fonts-to-select)
   (let ((available-fonts (font-family-list)))
     (car (chicken/filter (lambda (elt) (member elt available-fonts)) fonts-to-select))))
 #+end_src
-
 Now the font proper selection
 #+BEGIN_SRC emacs-lisp
 (let ((base-size 12)
-      (code-font (chicken/select-first-available-font '("PragmataPro Liga" "PragmataPro" "Consolas" "Courrier New")))
-      (variable-font (chicken/select-first-available-font '("PragmataPro Liga" "PragmataPro" "Segoe UI")))
-      (unicode-font (chicken/select-first-available-font '("PragmataPro Liga" "PragmataPro" "Segoe UI")))
-      (serif-font (chicken/select-first-available-font '("Iosevka Slab" "Courrier New" "Courrier New"))))
+      (code-font (chicken/select-first-available-font
+                  '("PragmataPro Liga" "PragmataPro" "Iosevka" "Iosevka SS08" "Consolas" "Courrier New")))
+      (variable-font (chicken/select-first-available-font
+                      '("PragmataPro Liga" "PragmataPro" "Iosevka Extended" "Iosevka SS08 Extended" "Segoe UI")))
+      (unicode-font (chicken/select-first-available-font
+                     '("PragmataPro Liga"
+                       "PragmataPro"
+                       "Segoe Color Emoji"
+                       ;;"Iosevka SS08 Light"
+                       "Iosevka SS08"
+                       "Iosevka"
+                       "Segoe UI")))
+      (serif-font (chicken/select-first-available-font
+                   '("Iosevka Slab" "Courrier New" "Courrier New"))))
   (setq doom-font
         (font-spec :family code-font :size base-size)
         doom-variable-pitch-font
@@ -125,6 +172,15 @@ PragmataPro's ligatures have been enabled within ~init.el~ though the
 ~pretty-code~ layer and it's optional specialization for this font. No more
 setting is to be done for this font. Yet I wonder if I want to determine how to
 add specific replacements (like ~lambda → λ~ ).
+*** TODO Implement a font switch on light/dark theme switch
+Gruvbox-light doesn't need a font as think as its dark alternative.
+*** TODO Visual tweaks
+#+begin_src emacs-lisp
+(custom-set-faces!
+  '(line-number nil :slant 'italic)
+  '(org-quote nil :inherit 'fixed-pitch-serif))
+#+end_src
+
 ** Tweaks
 *** Window borders
 Nothing really fancy yet, I'm content with how Doom looks right now. In the
@@ -147,25 +203,74 @@ so I can directly fallback on the unicode symbols. Allows me to tone down the
 visual noise.
 
 #+BEGIN_SRC emacs-lisp
-(if (member "github-octicons" (font-family-list))
+(after! doom-modeline
+  (if (member "github-octicons" (font-family-list))
+      (progn
+        (setq doom-modeline-icon t)
+        (setq doom-modeline-major-mode-icon t))
     (progn
-      (setq doom-modeline-icon t)
-      (setq doom-modeline-major-mode-icon t))
-  (progn
-    (setq doom-modeline-icon nil)
-    (setq doom-modeline-unicode-fallback t)))
-
-;; FIXME What does it lack to work?
-;;(setq doom-modeline-enable-word-count t)
-;;(setq doom-modeline-continuous-word-count-modes
-;;      '(markdown-mode gfm-mode org-mode))
+      (setq doom-modeline-icon nil)
+      (setq doom-modeline-unicode-fallback t)))
+
+  ;; FIXME What does it lack to work?
+  ;;(setq doom-modeline-enable-word-count t)
+  ;;(setq doom-modeline-continuous-word-count-modes
+  ;;      '(markdown-mode gfm-mode org-mode))
+
+  ;; HACK @work No really need right now to hack with encoding yet.
+  (setq doom-modeline-buffer-encoding nil))
 #+END_SRC
-*** Line numbers
-I like my line numbers in italic, for no sensible reason. It just looks good to
-me.
+*** TODO Top-modeline
+Inspired from [[https://github.com/rougier/elegant-emacs/blob/master/elegance.el#L150][Elegant-Emacs]].
+
+
 #+begin_src emacs-lisp
-(custom-set-faces!
- '(line-number :slant italic))
+(after! doom-themes
+  (custom-set-faces!
+    `(header-line
+      :inherit 'variable-pitch
+      :underline t
+      :foreground ,(doom-color 'base6))))
+
+
+(defun staging/reload-header-line-theme()
+  (setq chicken--header-line-width
+        (window-font-width (selected-window) 'header-line)))
+(staging/reload-header-line-theme)
+#+end_src
+
+
+#+begin_src emacs-lisp
+(define-key mode-line-major-mode-keymap [header-line]
+  (lookup-key mode-line-major-mode-keymap [mode-line]))
+
+(add-hook 'doom-load-theme-hook 'staging/reload-header-line-theme)
+
+(defun mode-line-render (left right)
+  (let* ((available-width (- (/ (window-width (selected-window) t) chicken--header-line-width) (length left) )))
+    (format (format "%%s  %%%ds" available-width) left right)))
+(setq-default header-line-format
+              '((:eval
+                 (mode-line-render
+                  (format-mode-line (list
+                                     (propertize "☰" 'face `(:inherit mode-line-buffer-id)
+                                                 'help-echo "Mode(s) menu"
+                                                 'mouse-face 'mode-line-highlight
+                                                 'local-map   mode-line-major-mode-keymap)
+                                     (propertize " %b " 'face `(:underline nil :foreground ,(doom-color 'base7)))
+                                     (if (and buffer-file-name (buffer-modified-p))
+                                         (propertize "*" 'face `(:inherit header-line)))))
+                  (format-mode-line
+                   (propertize "%4l:%2c  " 'face `(:inherit header-line)))))))
+(setq-default mode-line-format nil)
+#+end_src
+
+#+RESULTS:
+
+*** TODO Hide modeline for org
+#+begin_src emacs-lisp
+(after! org
+  (add-hook 'org-mode-hook (lambda () (setq-local display-line-numbers nil))))
 #+end_src
 * Python
 ** Python-x
@@ -206,9 +311,15 @@ configurations later.
 ** TODO Org Bullets
 Doom's default bullets, using ~org-superstar~, for org doesn't work perfectly in
 Windows. Let's use another set that'll work on my computers.
-#+BEGIN_SRC emacs-lisp
+#+BEGIN_SRC emacs-lisp :tangle no
 (setq org-superstar-headline-bullets-list '("■" "▩" "▦" "▨" "▤" "□"))
 #+END_SRC
+
+The new one
+#+BEGIN_SRC emacs-lisp
+(setq org-superstar-headline-bullets-list '("⧫"))
+#+END_SRC
+
 ** TODO Todo lists
 I'd like to track when I finish tasks. I'm not feeling that adding a note each
 time I close an item might be the best thing as I'd get tired of the prompt
@@ -221,26 +332,31 @@ Here will be located a routine to determine which folder we want to write the
 default brain(s) down.
 #+BEGIN_SRC emacs-lisp
 ;; TODO proper folder
-(add-hook! org-brain
-  (setq org-brain-path "c:/Notes/Work/Brain"))
+(when (eq system-type 'windows-nt)
+  (add-hook! org-brain
+  (setq org-brain-path "c:/Notes/Work/Brain")))
 #+END_SRC
 
 A small fix to avoid org-brain's key bindings be overwritten by evil.
 #+BEGIN_SRC emacs-lisp
-(add-hook! org-brain
+(after! org-brain
   (evil-set-initial-state 'org-brain-visualize-mode 'emacs))
 #+END_SRC
 
 Working icon display with ~all-the-icons~ to have a small icon before various
 kind of resource links.
 #+BEGIN_SRC emacs-lisp
-(add-hook! org-brain
+(after! org-brain
   (defun org-brain-insert-resource-icon (link)
     "Insert an icon, based on content of org-mode LINK."
     (let ((starts_with_http (string-prefix-p "http" link)))
       (insert (format "%s "
                       (cond
                        ;; File extensions
+
+                       ;; TODO use string-suffix-p everywhere or string-match?
+                       ;; The latter might give wrong results on filenames with
+                       ;; multiple extensions.
                        ((string-suffix-p ".pdf" link)
                         (all-the-icons-octicon "file-pdf"))
                        ((string-match "\\.cpp" link)
@@ -284,12 +400,43 @@ Here's some keybindings vaguely inspired from my experience with Spacemacs.
 (map! :mode org-mode
       :leader
       ;; Narrow
+      :desc "narrow" "mN" nil
       :desc "Narrow to subtree" "mNs" #'org-narrow-to-subtree
       :desc "Toggle subtree narrowing" "mNt" #'org-toggle-narrow-to-subtree
       :desc "Narrow to element" "mNe" #'org-narrow-to-element
       :desc "Narrow to element" "mNb" #'org-narrow-to-block
       :desc "Widen" "mNw" #'widen)
 #+END_SRC
+** TODO Org-brain
+*** TODO Ascii-art-to-unicode decoration
+This snippet, slightly edited from the code available on org-brain's [[https://github.com/Kungsgeten/org-brain][repository
+page]] uses ascii-art-to-unicode to draw the inheritance diagram with box drawing
+characters.
+#+begin_src emacs-lisp
+(after! org-brain
+  (defface aa2u-face '((t . nil))
+    "Face for aa2u box drawing characters")
+  (advice-add #'aa2u-1c :filter-return
+              (lambda (str) (propertize str 'face 'aa2u-face)))
+  (defun aa2u-org-brain-buffer ()
+    (let ((inhibit-read-only t))
+      (make-local-variable 'face-remapping-alist)
+      (add-to-list 'face-remapping-alist
+                   '(aa2u-face . org-brain-wires))
+      (ignore-errors (aa2u (point-min) (point-max)))))
+  (add-hook 'org-brain-after-visualize-hook #'aa2u-org-brain-buffer))
+#+end_src
+** TODO Org-Agenga
+*** TODO French day names
+#+begin_src emacs-lisp
+(after! org
+  (setq calendar-week-start-day 1
+        calendar-day-name-array ["Dimanche" "Lundi" "Mardi" "Mercredi"
+                                 "Jeudi" "Vendredi" "Samedi"]
+        calendar-month-name-array ["Janvier" "Février" "Mars" "Avril" "Mai"
+                                   "Juin" "Juillet" "Août" "Septembre"
+                                   "Octobre" "Novembre" "Décembre"]))
+#+end_src
 * Blog writing
 I have a [[https://retroactive.me][blog]]. I want to use emacs as my platform to type bits and bobs on it.
 
@@ -354,7 +501,7 @@ if the current project is the root of a Hugo-powered site."
 #+END_SRC
 ** PROJ Convert GIF to videos
 I like GIFs, that's a fact. But neither your bandwidth nor your CPU will
-appreciate them. It's soon 2020 and GIFs are one of the most known ways to share
+appreciate them. It's past 2020 and GIFs are one of the most known ways to share
 a small video but it is one of the heaviest way one could do on the internet.
 Why keep continuing using it, except for pixel perfect (256) colors when most of
 the time a little encoding will lose little details but a lot of filesize?
@@ -475,16 +622,16 @@ convert it automatically into mp4 and webm."
 #+END_SRC
 
 *** TODO A shortcut mapping
-Finally, I would like to make a shortcut to launch the conversion function to
+I would like to make a shortcut to launch the conversion function to
 quickly get things done. I need to find a proper wrapper for that and to read
 more Doom Emacs' documentation to figure how and where to scope the mapping.
-#+BEGIN_SRC emacs-lisp :tangle no
+#+BEGIN_SRC emacs-lisp
 (map! (:when
         (functionp 'chicken/search-everything))
       :leader
       :desc "Everything" "sE" #'chicken/search-everything)
 #+END_SRC
-* PROJ Character insertion
+* PROJ Character/sequences insertion
 ** STRT Basic principle
 #+BEGIN_SRC emacs-lisp
 ;; Note, I could build the list by concating the character's unicode name and itself.
@@ -510,7 +657,7 @@ the proper character map to list."""
     (message (symbol-name (cdr (assoc entry map))))))
 
 (defun chicken/insert-user-character (id)
-"""Another level of wrapper. This one should be pretty much
+  """Another level of wrapper. This one should be pretty much
 useable as-is as an user-editable replacement of insert-char
 after giving an argument."""
   (insert-char
@@ -522,9 +669,21 @@ after giving an argument."""
     #'(lambda () (interactive) (chicken/insert-user-character inner-id))))
 
 (map! (:when (boundp 'lexical-let)
-        :leader ; Use leader key from now on
-        :desc "Misc character insert" "iM" (chicken/create-user-character-inserter 'misc)))
+       :leader ; Use leader key from now on
+       :desc "Misc character insert" "iM" (chicken/create-user-character-inserter 'misc)))
+        #+END_SRC
+** TODO Kaomoji shortcut mapping
+Windows' emoji panel is great but not convenient enough when focusing on the
+keyboard. Let's add a mapping to quickly insert various kaomojis.
+#+BEGIN_SRC emacs-lisp
+(map! (:leader ; Use leader key from now on
+       :desc "Kaomoji" "iK" nil
+       :desc "Shrug" "iKs" (lambda ()(interactive) (insert "¯\\_(ツ)_/¯"))
+       :desc "Shrug (clip)" "iKS" (lambda ()(interactive) (kill-new "¯\\_(ツ)_/¯"))))
 #+END_SRC
+
+I have further questions adressed to myself regarding the mental sanity behind
+such feature.
 ** TODO Pragmata's own characters
 * Unsorted Functions
 ** Search Everything with Everything
@@ -539,13 +698,14 @@ function based on Ivy to let me jump on any file with the command line version.
 First, the function that will feed ~ivy-read~. It assumes ~es.exe~ is in your
 ~PATH~.
 #+BEGIN_SRC emacs-lisp
-(defun chicken/counsel-es-function (str)
-  (or
-   (ivy-more-chars)
-   (progn
-     (counsel--async-command
-      (format "es.exe %s" str))
-     '("" "working..."))))
+(when (eq system-type 'windows-nt)
+  (defun chicken/counsel-es-function (str)
+    (or
+     (ivy-more-chars)
+     (progn
+       (counsel--async-command
+        (format "es.exe %s" str))
+       '("" "working...")))))
 #+END_SRC
 
 Then the search function. It is defined when the executable ~es.exe~ can be
@@ -553,6 +713,7 @@ found in your ~PATH~ environment variable. The function is largely inspired by
 Ivy's own examples.
 #+BEGIN_SRC emacs-lisp
 (when (and
+       (eq system-type 'windows-nt)
        (executable-find "es.exe")
        (featurep! :completion ivy))
   (defun chicken/search-everything ()
@@ -579,9 +740,9 @@ you have the executable available by checking if the function to be called is
 available.
 #+BEGIN_SRC emacs-lisp
 (map! (:when
-        (functionp 'chicken/search-everything))
+        (functionp 'chicken/search-everything)
       :leader
-      :desc "Everything" "sE" #'chicken/search-everything)
+      :desc "Everything" "sE" #'chicken/search-everything))
 #+END_SRC
 * Unsorted Tweaks
 ** Treat the underscore as a word character

+ 0 - 8
packages.el

@@ -1,8 +0,0 @@
-;; -*- no-byte-compile: t; -*-
-;;; .doom.d/packages.el
-
-(package! vterm :ignore (eq system-type 'windows-nt))
-
-(package! graphviz-dot-mode)
-
-(package! python-x)