Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert character name or alias #12

Open
abarocio80 opened this issue Sep 16, 2023 · 1 comment
Open

Insert character name or alias #12

abarocio80 opened this issue Sep 16, 2023 · 1 comment
Assignees

Comments

@abarocio80
Copy link

I have a suggestion to insert a character's name or alias:

(defun orgn--select-character-name-or-alias ()
  "Selects the character name or alias from the character notes."
  (replace-regexp-in-string
   ".* --- " ""
   (completing-read
    "Selecciona un nombre de personaje: "
    (let ((default-directory (expand-file-name (org-novelist--story-root-folder))))
      (flatten-list
       (mapcar
	(lambda (file)
	  (with-current-buffer (find-file-noselect file)
	    (let* ((kw (org-collect-keywords '("title" "aliases")))
		   (full (nth 1 (car kw)))
		   (alias (nth 1 (cadr kw))))
	      (flatten-list
	       (list
		(format "%s" full)
		(when alias
		  (mapcar
		   (lambda (n)
		     (format "%s --- %s" full (string-trim n)))
		   (split-string alias ","))))))))
	(directory-files (expand-file-name "Notes" default-directory) t "character-.*\\.org$"))))
    nil t)))

(defun org-novelist-insert-character-name ()
  "Iserts a character's name or alias from the character notes."
  (interactive)
  (insert (orgn--select-character-name-or-alias)))

I didn't want to make a full PR, so I just drop it here.

I hope it is useful (I know it is for me).

@sympodius
Copy link
Owner

Sorry, I should have responded to this a while ago. This is a cool idea! I'll try to include this feature in a future update. Thanks for sharing!

@sympodius sympodius self-assigned this Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants