Skip to content

Instantly share code, notes, and snippets.

@camparijet
Created January 28, 2018 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camparijet/b0da2a66a86fb5cd4219b9be561a3323 to your computer and use it in GitHub Desktop.
Save camparijet/b0da2a66a86fb5cd4219b9be561a3323 to your computer and use it in GitHub Desktop.
Show the same name org-files with different identifier given by parent directory name.
(defun ht-org-get-category-string (str-filename)
(when (string-match "[^/]*/[^/]*\\.[^/]*$" str-filename)
(progn
(let ((str (match-string 0 str-filename)))
(when (string-match "\\.[^/]*$" str)
(replace-match "" nil nil str)
)
)
)
)
)
(defun test-ht-org-get-category-string-match (test-str ans-str)
(equal ans-str (ht-org-get-category-string test-str))
)
(test-ht-org-get-category-string-match "~/workspace/org/index.org" "org/index")
(defun org-get-category (&optional pos force-refresh)
"Get the category applying to position POS."
(save-match-data
(when force-refresh (org-refresh-category-properties))
(let ((pos (or pos (point))))
;; (or (get-text-property pos 'org-category)
;; (progn (org-refresh-category-properties)
;; (get-text-property pos 'org-category))
(or
(concat (ht-org-get-category-string (buffer-file-name (current-buffer))) "\t")
(progn (org-refresh-category-properties)
(concat (ht-org-get-category-string (buffer-file-name (current-buffer))) "\t")
)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment