Remove language-specific source block hydra heads
This commit is contained in:
parent
6d85a1d42e
commit
0cbfa4c24c
41
init.org
41
init.org
|
@ -803,15 +803,12 @@ _u_: next word ^_l_: edit lines^ _s_: next whole symbol
|
||||||
**** org block
|
**** org block
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defhydra my-org-hydra-block (:color blue)
|
(defhydra my-org-hydra-block (:color blue)
|
||||||
"Org source block"
|
"Org block"
|
||||||
("e" (my-org-hydra-insert-block "SRC" "emacs-lisp") "Emacs Lisp")
|
("l" (my-org-insert-block "SRC" nil) "Source")
|
||||||
("t" (my-org-hydra-insert-block "SRC" "emacs-lisp :tangle test :load test") "Emacs Lisp test")
|
("t" (my-org-insert-block "SRC" nil ":tangle test :load test") "Source test")
|
||||||
("E" (my-org-hydra-insert-block "SRC" "emacs-lisp :tangle no :load no") "Emacs Lisp example")
|
("e" (my-org-insert-block "SRC" nil ":tangle no :load no") "Source example")
|
||||||
("h" (my-org-hydra-insert-block "SRC" "sh") "Shell")
|
("o" (my-org-insert-block "QUOTE") "quote")
|
||||||
("o" (my-org-hydra-insert-block "QUOTE") "quote")
|
("v" (my-org-insert-block "VERSE") "verse"))
|
||||||
("v" (my-org-hydra-insert-block "VERSE") "verse")
|
|
||||||
("s" (my-org-hydra-insert-block "SRC" "scheme") "Scheme")
|
|
||||||
("l" (my-org-hydra-insert-block "SRC" "lisp") "Common Lisp"))
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
**** org navigation
|
**** org navigation
|
||||||
|
@ -3845,17 +3842,33 @@ SLIME opens CLHS links in Firefox, but I'd rather open them in Tor Browser; Tor
|
||||||
(defun contrapunctus-disable-nameless-key ()
|
(defun contrapunctus-disable-nameless-key ()
|
||||||
(define-key nameless-mode-map (kbd "C-c C--") nil))
|
(define-key nameless-mode-map (kbd "C-c C--") nil))
|
||||||
|
|
||||||
(defun my-org-hydra-insert-block (type &optional lang)
|
(defun my-org-insert-block (type &optional lang header-args)
|
||||||
"Insert block of TYPE at point, or at beginning and end of region.
|
"Insert block of TYPE at point, or at beginning and end of region.
|
||||||
TYPE should be an Org block type, e.g. SRC, QUOTE, etc.
|
TYPE should be an Org block type, e.g. SRC, QUOTE, etc.
|
||||||
|
|
||||||
If TYPE is SRC, LANG should be the name of the language as a string, e.g. \"emacs-lisp\"."
|
If TYPE is SRC, LANG should be the name of the language as a string, e.g. \"emacs-lisp\".
|
||||||
(let* ((column (- (point) (point-at-bol)))
|
|
||||||
|
If LANG is not supplied, use the value of
|
||||||
|
`my-org-src-default-lang'. If `my-org-src-default-lang' is nil,
|
||||||
|
prompt the user for a language."
|
||||||
|
(let* ((src-block-p (equal type "SRC"))
|
||||||
|
(lang (cond ((stringp lang) lang)
|
||||||
|
((and (bound-and-true-p my-org-src-default-lang)
|
||||||
|
(stringp my-org-src-default-lang))
|
||||||
|
my-org-src-default-lang)
|
||||||
|
(src-block-p
|
||||||
|
(completing-read "Source block language: "
|
||||||
|
(mapcar #'cl-first org-src-lang-modes)))
|
||||||
|
(t nil)))
|
||||||
|
(column (- (point) (point-at-bol)))
|
||||||
(indent (make-string column ?\s))
|
(indent (make-string column ?\s))
|
||||||
(region-start (region-beginning))
|
(region-start (region-beginning))
|
||||||
(region-end (region-end))
|
(region-end (region-end))
|
||||||
(start-string (format "#+BEGIN_%s %s\n" type
|
(start-string (format "#+BEGIN_%s %s%s\n" type
|
||||||
(if (stringp lang) lang "")))
|
(if src-block-p lang "")
|
||||||
|
(if (and src-block-p header-args)
|
||||||
|
(format " %s" header-args)
|
||||||
|
"")))
|
||||||
(end-string (format "%s#+END_%s\n" indent type)))
|
(end-string (format "%s#+END_%s\n" indent type)))
|
||||||
;; create a block around a region - preserve position of point
|
;; create a block around a region - preserve position of point
|
||||||
(cond ((region-active-p)
|
(cond ((region-active-p)
|
||||||
|
|
Loading…
Reference in New Issue