Skip to content

Insert character name or alias #12

@abarocio80

Description

@abarocio80

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).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions