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

Feature request: use tag as buffer name #190

Open
QiangF opened this issue Nov 12, 2024 · 1 comment
Open

Feature request: use tag as buffer name #190

QiangF opened this issue Nov 12, 2024 · 1 comment

Comments

@QiangF
Copy link

QiangF commented Nov 12, 2024

Because note id has no meaning to the user. I would suggest like this:

   (defun ekg-edit (note)
     "Edit an existing NOTE."
     (let ((buf (get-buffer-create (format "*EKG Edit: %s*"
                                           (string-join (seq-take
                                                         (remove-if #'ekg-date-tag-p (ekg-note-tags note))
                                                         3) " ")))))
       (set-buffer buf)
       (when (= 0 (buffer-size))
         (when (ekg-note-mode note)
           (funcall (ekg-note-mode note)))
         (ekg-edit-mode 1)
         (ekg--set-local-variables)
         (setq-local ekg-note (copy-ekg-note note) ; shallow copy
                     ekg-note-orig-note (copy-tree note) ; deep copy to avoid later change
                     ekg-note-orig-id (ekg-note-id note))
         ;; When re-editing a note that's a draft, we need to remove the draft tag
         ;; so that when we save it, it's not a draft anymore.
         (setf (ekg-note-tags ekg-note)
               (seq-difference (ekg-note-tags ekg-note) (list ekg-draft-tag)))
         (ekg-edit-display-metadata)
         (setq-local ekg-note-orig-fields (seq-uniq
                                           (mapcar #'car (ekg--metadata-fields note))
                                           #'string=))
         (insert (ekg-insert-inlines-representation
                  (ekg-note-text note) (ekg-note-inlines note)))
         (goto-char (+ 1 (overlay-end (ekg--metadata-overlay))))
         (mapc #'ekg-maybe-function-tag (ekg-note-tags ekg-note))
         (if (and (eq (ekg-note-mode note) 'org-mode)
                  ekg-notes-display-images)
             (org-redisplay-inline-images)))
       (set-buffer-modified-p nil)
       (pop-to-buffer buf)))
@ahyatt
Copy link
Owner

ahyatt commented Nov 17, 2024

This is reasonable, at least adding the tags seems like a good idea. I had the ID in there to make sure you didn't have two buffers with the same title, but I suppose there's existing packages like uniquify that can take care of that. I have some other ideas beyond what you are saying, let me see what works.

Thanks for the suggestion!

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