Compare commits
2 Commits
3674d11cd2
...
291e0f055b
Author | SHA1 | Date | |
---|---|---|---|
291e0f055b | |||
07afc05210 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
/*.elc
|
||||||
|
/.eask/
|
||||||
|
/dist/
|
1
Eask
1
Eask
@ -11,6 +11,7 @@
|
|||||||
(script "test" "echo \"Error: no test specified\" && exit 1")
|
(script "test" "echo \"Error: no test specified\" && exit 1")
|
||||||
|
|
||||||
(source "gnu")
|
(source "gnu")
|
||||||
|
(source "melpa")
|
||||||
|
|
||||||
(depends-on "emacs" "26.1")
|
(depends-on "emacs" "26.1")
|
||||||
(depends-on "ivy" "0.13")
|
(depends-on "ivy" "0.13")
|
||||||
|
@ -48,14 +48,9 @@
|
|||||||
; Vuepress headings ;
|
; Vuepress headings ;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defun conlanging--get-heading-slug ()
|
(defun conlanging--slugify (str)
|
||||||
"Select and return a heading and its slug."
|
"Slugify STR."
|
||||||
(let* ((settings (cdr (assq major-mode counsel-outline-settings)))
|
(let* ((slug (downcase str))
|
||||||
(heading (substring-no-properties (ivy-read "Heading: " (counsel-outline-candidates settings)
|
|
||||||
:preselect (max (1- counsel-outline--preselect) 0))))
|
|
||||||
;; keep only lowest heading
|
|
||||||
(heading (replace-regexp-in-string "\\`.*/" "" heading))
|
|
||||||
(slug (downcase heading))
|
|
||||||
;; only keep alphanumeric characters
|
;; only keep alphanumeric characters
|
||||||
(slug (replace-regexp-in-string "[^[:alnum:]]+" " " slug))
|
(slug (replace-regexp-in-string "[^[:alnum:]]+" " " slug))
|
||||||
(slug (string-trim slug))
|
(slug (string-trim slug))
|
||||||
@ -68,14 +63,33 @@
|
|||||||
(slug (replace-regexp-in-string "[óòōôö]" "o" slug))
|
(slug (replace-regexp-in-string "[óòōôö]" "o" slug))
|
||||||
(slug (replace-regexp-in-string "[ńǹñ]" "n" slug))
|
(slug (replace-regexp-in-string "[ńǹñ]" "n" slug))
|
||||||
(slug (replace-regexp-in-string "[úùûü]" "u" slug))
|
(slug (replace-regexp-in-string "[úùûü]" "u" slug))
|
||||||
(slug (replace-regexp-in-string "ý" "y" slug))
|
(slug (replace-regexp-in-string "ý" "y" slug)))
|
||||||
(slug (replace-regexp-in-string " " "-" slug)))
|
(replace-regexp-in-string " " "-" slug)))
|
||||||
|
|
||||||
|
(defun conlanging--get-heading-slug ()
|
||||||
|
"Select and return a heading and its slug."
|
||||||
|
(let* ((settings (cdr (assq major-mode counsel-outline-settings)))
|
||||||
|
(heading (substring-no-properties (ivy-read "Heading: " (counsel-outline-candidates settings)
|
||||||
|
:preselect (max (1- counsel-outline--preselect) 0))))
|
||||||
|
;; keep only lowest heading
|
||||||
|
(heading (replace-regexp-in-string "\\`.*/" "" heading))
|
||||||
|
(slug (conlanging--slugify heading)))
|
||||||
`(,heading . ,slug)))
|
`(,heading . ,slug)))
|
||||||
|
|
||||||
(defun conlanging--get-filename-no-ext ()
|
(defun conlanging--get-filename-no-ext ()
|
||||||
"Get file name of current buffer without its extension."
|
"Get file name of current buffer without its extension."
|
||||||
(file-name-sans-extension (file-name-nondirectory (buffer-file-name (buffer-base-buffer)))))
|
(file-name-sans-extension (file-name-nondirectory (buffer-file-name (buffer-base-buffer)))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun conlanging-store-heading-vuepress ()
|
||||||
|
"Store in kill ring a Vuepress link to current heading."
|
||||||
|
(interactive)
|
||||||
|
(let* ((filename (conlanging--get-filename-no-ext))
|
||||||
|
(heading (nth 4 (org-heading-components)))
|
||||||
|
(slug (conlanging--slugify heading)))
|
||||||
|
(org-link--add-to-stored-links (format "file:./%s.md#%s" filename slug)
|
||||||
|
heading)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun conlanging-insert-heading-vuepress ()
|
(defun conlanging-insert-heading-vuepress ()
|
||||||
"Insert vuepress-compatible link to heading."
|
"Insert vuepress-compatible link to heading."
|
||||||
|
Loading…
Reference in New Issue
Block a user