Issues with work-related stuff, like Ansible and Markdown
Now doing a lot of work with Markdown, and need to add linting and other features.
This commit is contained in:
parent
f1fa3742a0
commit
24d13c1a07
3 changed files with 52 additions and 58 deletions
19
ha-org.org
19
ha-org.org
|
@ -696,7 +696,7 @@ Bindings specific to org files:
|
||||||
Limit the number of exporters to the ones that I would use:
|
Limit the number of exporters to the ones that I would use:
|
||||||
#+name: ox-exporters
|
#+name: ox-exporters
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(setq org-export-backends '(ascii html icalendar md odt))
|
(setq org-export-backends '(ascii html md texinfo odt))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
I have a special version of tweaked [[file:elisp/ox-confluence.el][Confluence exporter]] for my org files:
|
I have a special version of tweaked [[file:elisp/ox-confluence.el][Confluence exporter]] for my org files:
|
||||||
|
@ -711,15 +711,16 @@ I have a special version of tweaked [[file:elisp/ox-confluence.el][Confluence ex
|
||||||
|
|
||||||
And Graphviz configuration using [[https://github.com/ppareit/graphviz-dot-mode][graphviz-dot-mode]]:
|
And Graphviz configuration using [[https://github.com/ppareit/graphviz-dot-mode][graphviz-dot-mode]]:
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package graphviz-dot-mode
|
(use-package graphviz-dot-mode
|
||||||
:mode "\\.dot\\'"
|
:mode "\\.dot\\'"
|
||||||
:init
|
:init
|
||||||
(setq tab-width 4
|
(setq tab-width 4
|
||||||
graphviz-dot-indent-width 2
|
graphviz-dot-indent-width 2
|
||||||
graphviz-dot-auto-indent-on-newline t
|
graphviz-dot-auto-indent-on-newline t
|
||||||
graphviz-dot-auto-indent-on-braces t
|
graphviz-dot-auto-indent-on-braces t
|
||||||
graphviz-dot-auto-indent-on-semi t))
|
graphviz-dot-auto-indent-on-semi t))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** HTML Style
|
*** HTML Style
|
||||||
|
|
||||||
I’m not afraid of HTML, but I like the idea of doing my HTML work in a Lisp-like way using the [[https://github.com/tonyaldon/jack][jack-html project]]:
|
I’m not afraid of HTML, but I like the idea of doing my HTML work in a Lisp-like way using the [[https://github.com/tonyaldon/jack][jack-html project]]:
|
||||||
|
|
|
@ -33,25 +33,25 @@ Moving by lines is our default navigation mode, but for Yaml and Python, that do
|
||||||
|
|
||||||
The obvious keybindings are ~M-h/j/k/l~ … but that is used … well, somewhat. In org files, this is a way to move the outline of subtrees around. Useful, and =spatial-navigate= wouldn’t be helpful in org files anyway.
|
The obvious keybindings are ~M-h/j/k/l~ … but that is used … well, somewhat. In org files, this is a way to move the outline of subtrees around. Useful, and =spatial-navigate= wouldn’t be helpful in org files anyway.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp :tangle no
|
||||||
(use-package spatial-navigate
|
(use-package spatial-navigate
|
||||||
:straight (:repo "https://codeberg.org/ideasman42/emacs-spatial-navigate")
|
:straight (:repo "https://codeberg.org/ideasman42/emacs-spatial-navigate")
|
||||||
:config
|
:config
|
||||||
(pretty-hydra-define spatial-navigate (:color amaranth :quit-key "q")
|
(pretty-hydra-define spatial-navigate (:color amaranth :quit-key "q")
|
||||||
("Box"
|
("Box"
|
||||||
(("k" spatial-navigate-backward-vertical-box "up")
|
(("k" spatial-navigate-backward-vertical-box "up")
|
||||||
("j" spatial-navigate-forward-vertical-box "Down")
|
("j" spatial-navigate-forward-vertical-box "Down")
|
||||||
("h" spatial-navigate-backward-horizontal-box "Down")
|
("h" spatial-navigate-backward-horizontal-box "Down")
|
||||||
("l" spatial-navigate-forward-horizontal-box "Down"))
|
("l" spatial-navigate-forward-horizontal-box "Down"))
|
||||||
"Bar"
|
"Bar"
|
||||||
(("K" spatial-navigate-backward-vertical-bar "up")
|
(("K" spatial-navigate-backward-vertical-bar "up")
|
||||||
("J" spatial-navigate-forward-vertical-bar "Down")
|
("J" spatial-navigate-forward-vertical-bar "Down")
|
||||||
("H" spatial-navigate-backward-horizontal-bar "Down")
|
("H" spatial-navigate-backward-horizontal-bar "Down")
|
||||||
("L" spatial-navigate-forward-horizontal-bar "Down")))))
|
("L" spatial-navigate-forward-horizontal-bar "Down")))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
And we can attach this menu to the “g” section:
|
And we can attach this menu to the “g” section:
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp :tangle no
|
||||||
(use-package spatial-navigate
|
(use-package spatial-navigate
|
||||||
:general
|
:general
|
||||||
(:states '(normal visual motion operator)
|
(:states '(normal visual motion operator)
|
||||||
|
@ -115,9 +115,6 @@ Doing a lot of [[https://github.com/yoshiki/yaml-mode][YAML work]], but the =ya
|
||||||
("h" ha-yaml-prev-section "Previous"))))))
|
("h" ha-yaml-prev-section "Previous"))))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+RESULTS:
|
|
||||||
: major-mode-hydras/yaml-ts-mode/body
|
|
||||||
|
|
||||||
Allow this mode in Org blocks:
|
Allow this mode in Org blocks:
|
||||||
#+begin_src emacs-lisp :results silent
|
#+begin_src emacs-lisp :results silent
|
||||||
(add-to-list 'org-babel-load-languages '(yaml-ts . t))
|
(add-to-list 'org-babel-load-languages '(yaml-ts . t))
|
||||||
|
@ -202,12 +199,20 @@ I adapted this code from the [[https://github.com/emacsmirror/poly-ansible][poly
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
We need to make sure the =mixed-pitch-mode= doesn’t screw things up.
|
We need to make sure the =mixed-pitch-mode= doesn’t screw things up.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(add-hook 'poly-yaml-jinja2-mode-hook (lambda () (mixed-pitch-mode -1)))
|
(add-hook 'poly-yaml-jinja2-mode-hook (lambda () (mixed-pitch-mode -1)))
|
||||||
|
|
||||||
;; (add-hook 'yaml-ts-mode-hook 'poly-yaml-jinja2-mode)
|
|
||||||
#+end_src
|
#+end_src
|
||||||
#+begin_src yaml-ts
|
|
||||||
|
We /can/ hook this up to Org, via:
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(add-to-list 'org-babel-load-languages '(poly-yaml-jinja2 . t))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
Now we can use either =yaml-ts= or =poly-yaml-jinja2= (which perhaps we should make an alias?):
|
||||||
|
|
||||||
|
#+begin_src poly-yaml-jinja2 :tangle no
|
||||||
---
|
---
|
||||||
# Let's see how this works
|
# Let's see how this works
|
||||||
- name: Busta move
|
- name: Busta move
|
||||||
|
@ -244,6 +249,7 @@ The YAML files get access Ansible’s documentation using the [[https://github.c
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package ansible-doc
|
(use-package ansible-doc
|
||||||
|
:after yaml-ts-mode
|
||||||
:hook (yaml-ts-mode . ansible-doc-mode)
|
:hook (yaml-ts-mode . ansible-doc-mode)
|
||||||
:config
|
:config
|
||||||
;; (add-to-list 'exec-path (expand-file-name "~/.local/share/mise/installs/python/3.10/bin/ansible-doc"))
|
;; (add-to-list 'exec-path (expand-file-name "~/.local/share/mise/installs/python/3.10/bin/ansible-doc"))
|
||||||
|
|
|
@ -213,6 +213,7 @@ Why use [[https://www.flycheck.org/][flycheck]] over the built-in =flymake=? Spe
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package flycheck
|
(use-package flycheck
|
||||||
|
:straight (:host github :repo "flycheck/flycheck")
|
||||||
:init
|
:init
|
||||||
(setq next-error-message-highlight t)
|
(setq next-error-message-highlight t)
|
||||||
:bind (:map flycheck-error-list-mode-map
|
:bind (:map flycheck-error-list-mode-map
|
||||||
|
@ -1115,7 +1116,6 @@ Most project =README= files and other documentation use [[https://jblevins.org/p
|
||||||
Also, I like Markdown is look like a word processor, similarly to my org files:
|
Also, I like Markdown is look like a word processor, similarly to my org files:
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package markdown-mode
|
(use-package markdown-mode
|
||||||
:straight (:host github :repo "jrblevin/markdown-mode")
|
|
||||||
:mode ((rx ".md" string-end) . gfm-mode)
|
:mode ((rx ".md" string-end) . gfm-mode)
|
||||||
:init (setq markdown-command (expand-file-name "markdown" "~/bin")
|
:init (setq markdown-command (expand-file-name "markdown" "~/bin")
|
||||||
markdown-open-command (expand-file-name "markdown-open" "~/bin")
|
markdown-open-command (expand-file-name "markdown-open" "~/bin")
|
||||||
|
@ -1135,38 +1135,25 @@ Also, I like Markdown is look like a word processor, similarly to my org files:
|
||||||
", e" '("export" . markdown-export)
|
", e" '("export" . markdown-export)
|
||||||
", p" '("preview" . markdown-preview)))
|
", p" '("preview" . markdown-preview)))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Note that the markdown-specific commands use the ~C-c C-c~ and ~C-c C-s~ prefixes.
|
Note that the markdown-specific commands use the ~C-c C-c~ and ~C-c C-s~ prefixes.
|
||||||
|
|
||||||
With the =markdown-header-scaling= set, we no longer need to color the headers in Markdown, nor many of the /garish/ colors.
|
Let’s make sure that [[https://www.flycheck.org/en/latest/languages.html#markdown][markdown]] is proper using [[https://pypi.org/project/pymarkdownlnt/][PyMarkdown]]. First, get the script installed globally:
|
||||||
|
|
||||||
|
#+begin_src sh
|
||||||
|
pip install pymarkdown
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
And then we can use it. For some reason, the =pymarkdown= (which I need to use from work) doesn’t seem to be part of the version of Flycheck available on Melpa, so…
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package markdown-mode
|
(use-package markdown-mode
|
||||||
:after org
|
:after flycheck
|
||||||
:config
|
:config
|
||||||
(let ((default-color (face-attribute 'default :foreground)))
|
(setq flycheck-markdown-pymarkdown-config ".pymarkdown.yml")
|
||||||
(set-face-attribute 'markdown-italic-face nil :foreground 'unspecified)
|
(flycheck-may-enable-checker 'markdown-pymarkdown))
|
||||||
(set-face-attribute 'markdown-bold-face nil :foreground 'unspecified)
|
|
||||||
(set-face-attribute 'markdown-pre-face nil
|
|
||||||
:foreground (face-attribute 'org-code :foreground))
|
|
||||||
(set-face-attribute 'markdown-code-face nil
|
|
||||||
:background (face-attribute 'org-block :background))
|
|
||||||
(set-face-attribute 'markdown-language-keyword-face nil
|
|
||||||
:foreground (face-attribute 'org-block-begin-line :foreground))
|
|
||||||
(set-face-attribute 'markdown-url-face nil
|
|
||||||
:foreground (face-attribute 'font-lock-comment-face :foreground))
|
|
||||||
(set-face-attribute 'markdown-header-face nil
|
|
||||||
:font ha-variable-header-font
|
|
||||||
:foreground default-color)
|
|
||||||
(when window-system
|
|
||||||
(dolist (level '(1 2 3 4))
|
|
||||||
(let ((md-level (make-face (make-symbol (format "markdown-header-face-%d" level))))
|
|
||||||
(org-level (nth (1- level) org-level-faces)))
|
|
||||||
(message "Setting %s size %.1f to %s" org-level (face-attribute org-level :height) md-level)
|
|
||||||
(print `(set-face-attribute ,md-level nil
|
|
||||||
:height ,(face-attribute org-level :height)))
|
|
||||||
(set-face-attribute md-level nil :foreground default-color
|
|
||||||
:height (face-attribute org-level :height)))))))
|
|
||||||
|
|
||||||
|
|
||||||
|
;; defcustom flycheck-markdown-pymarkdown-config
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Both the =markdown-command= and the =markdown-open-command= variables are called to render (and preview) a Markdown file (~C-c C-c o~), and calls the following scripts (which in turn, call =pandoc= as I depend on this for other org-related features):
|
Both the =markdown-command= and the =markdown-open-command= variables are called to render (and preview) a Markdown file (~C-c C-c o~), and calls the following scripts (which in turn, call =pandoc= as I depend on this for other org-related features):
|
||||||
|
|
Loading…
Reference in a new issue