Compare commits
No commits in common. "291e0f055b42d9803f8a2095896125b495d1c549" and "3674d11cd2793240458d413f956f8401269ccc57" have entirely different histories.
291e0f055b
...
3674d11cd2
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +0,0 @@
|
|||||||
/*.elc
|
|
||||||
/.eask/
|
|
||||||
/dist/
|
|
1
Eask
1
Eask
@ -11,7 +11,6 @@
|
|||||||
(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,9 +48,14 @@
|
|||||||
; Vuepress headings ;
|
; Vuepress headings ;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defun conlanging--slugify (str)
|
(defun conlanging--get-heading-slug ()
|
||||||
"Slugify STR."
|
"Select and return a heading and its slug."
|
||||||
(let* ((slug (downcase str))
|
(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 (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))
|
||||||
@ -63,33 +68,14 @@
|
|||||||
(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))
|
||||||
(replace-regexp-in-string " " "-" slug)))
|
(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