Fixed my new quote insertion and added more...
This commit is contained in:
parent
132404580a
commit
ed0a86acb7
1 changed files with 51 additions and 5 deletions
|
@ -48,8 +48,7 @@ Oh, and as I indent lists, they should change the /bulleting/ in a particular se
|
||||||
The =org-indent-indentation-per-level=, which defaults to =2= doesn’t really work well with variable-width fonts, so let’s make the spaces at the beginning of the line fixed:
|
The =org-indent-indentation-per-level=, which defaults to =2= doesn’t really work well with variable-width fonts, so let’s make the spaces at the beginning of the line fixed:
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package org
|
(use-package org
|
||||||
:config
|
:custom-face (org-indent ((t (:inherit fixed-pitch)))))
|
||||||
(set-face-attribute 'org-indent nil :inherit 'fixed-pitch))
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Typographic Quotes
|
** Typographic Quotes
|
||||||
According to [[http://endlessparentheses.com/prettify-your-quotation-marks.html][Artur Malabarba]] of [[http://endlessparentheses.com/prettify-you-apostrophes.html][Endless Parenthesis]] blog, I type either a /straight single or double quote/, ", Emacs actually inserts Unicode rounded quotes, like “this”. This idea isn’t how a file is /displayed/, but actually how the file is /made/. Time will tell if this idea works with my auxiliary functions on my phone, like [[https://play.google.com/store/apps/details?id=com.orgzly&hl=en_US&gl=US][Orgzly]] and [[https://github.com/amake/orgro][Orgro]].
|
According to [[http://endlessparentheses.com/prettify-your-quotation-marks.html][Artur Malabarba]] of [[http://endlessparentheses.com/prettify-you-apostrophes.html][Endless Parenthesis]] blog, I type either a /straight single or double quote/, ", Emacs actually inserts Unicode rounded quotes, like “this”. This idea isn’t how a file is /displayed/, but actually how the file is /made/. Time will tell if this idea works with my auxiliary functions on my phone, like [[https://play.google.com/store/apps/details?id=com.orgzly&hl=en_US&gl=US][Orgzly]] and [[https://github.com/amake/orgro][Orgro]].
|
||||||
|
@ -80,14 +79,15 @@ Stealing his function, and updating it a bit, so that “quotes” just work to
|
||||||
|
|
||||||
;; Don't do anything special in code blocks:
|
;; Don't do anything special in code blocks:
|
||||||
(if (and (derived-mode-p 'org-mode)
|
(if (and (derived-mode-p 'org-mode)
|
||||||
(org-in-block-p '("src" "latex" "html")))
|
(org-in-block-p '("src" "latex" "html" "example")))
|
||||||
(call-interactively #'self-insert-command)
|
(call-interactively #'self-insert-command)
|
||||||
|
|
||||||
;; Define some regular expressions to make the `cond' clearer:
|
;; Define some regular expressions to make the `cond' clearer:
|
||||||
(let ((existing-word (rx word-start))
|
(let ((existing-word (rx word-start))
|
||||||
(starting-anew (rx (or bol space)))
|
(starting-anew (rx (or bol space)))
|
||||||
(existing-endq (rx (or "'" "\"" (eval opening) (eval closing))
|
(existing-endq
|
||||||
(optional (any "=_/*")))))
|
(rx-to-string `(seq (or "'" "\"" ,opening ,closing)
|
||||||
|
(optional (any "=_/*"))))))
|
||||||
(cond
|
(cond
|
||||||
((looking-at existing-word) (insert opening))
|
((looking-at existing-word) (insert opening))
|
||||||
((looking-back starting-anew) (insert-pair))
|
((looking-back starting-anew) (insert-pair))
|
||||||
|
@ -135,6 +135,52 @@ What would be nice, is that if I end quotes using the functions above, that if I
|
||||||
|
|
||||||
(advice-add #'org-delete-backward-char :before #'ha-delete-quote-pairs)
|
(advice-add #'org-delete-backward-char :before #'ha-delete-quote-pairs)
|
||||||
|
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Can we do the same with ellipses?
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(defun ha-insert-dot-or-ellipsis ()
|
||||||
|
"Insert a `.' unless two have already be inserted.
|
||||||
|
In this case, insert an ellipsis instead."
|
||||||
|
(interactive)
|
||||||
|
(if (and (derived-mode-p 'org-mode)
|
||||||
|
(org-in-block-p '("src" "latex" "html" "example")))
|
||||||
|
(call-interactively #'self-insert-command)
|
||||||
|
(cond
|
||||||
|
((looking-back (rx "…")) (delete-backward-char 1)
|
||||||
|
(insert "⋯"))
|
||||||
|
((looking-back (rx "..")) (delete-backward-char 2)
|
||||||
|
(insert "…"))
|
||||||
|
(t (insert ".")))))
|
||||||
|
|
||||||
|
(define-key org-mode-map "." #'ha-insert-dot-or-ellipsis)
|
||||||
|
|
||||||
|
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Now I’m getting obsessive with elongating dashes:
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(defun ha-insert-long-dash ()
|
||||||
|
"Insert a `.' unless two have already be inserted.
|
||||||
|
In this case, insert an ellipsis instead."
|
||||||
|
(interactive)
|
||||||
|
(if (and (derived-mode-p 'org-mode)
|
||||||
|
(org-in-block-p '("src" "latex" "html" "example")))
|
||||||
|
(call-interactively #'self-insert-command)
|
||||||
|
(cond
|
||||||
|
((looking-back (rx "-")) (delete-backward-char 1)
|
||||||
|
(insert "—"))
|
||||||
|
((looking-back (rx "—")) (delete-backward-char 1)
|
||||||
|
(insert "⸺"))
|
||||||
|
((looking-back (rx "⸺")) (delete-backward-char 1)
|
||||||
|
(insert "⸻"))
|
||||||
|
((looking-back (rx "⸻")) (delete-backward-char 1)
|
||||||
|
(insert "------------------------------------------------------------"))
|
||||||
|
(t (insert "-")))))
|
||||||
|
|
||||||
|
(define-key org-mode-map "-" #'ha-insert-long-dash)
|
||||||
|
|
||||||
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
* Org Beautify
|
* Org Beautify
|
||||||
I really want to use the Org Beautify package, but it overrides my darker themes (and all I really want is headlines to behave).
|
I really want to use the Org Beautify package, but it overrides my darker themes (and all I really want is headlines to behave).
|
||||||
|
|
Loading…
Reference in a new issue