Coder Social home page Coder Social logo

Comments (7)

protesilaos avatar protesilaos commented on July 28, 2024

Thank you @tjstankus! I just pushed the changes. Please let me know if it now works for you.

from denote.

tjstankus avatar tjstankus commented on July 28, 2024

Thank you for addressing this so quickly @protesilaos! Unfortunately, I'm still hitting the same issue after updating. To provide more context, I'm using doom-emacs and the denote-specific part of my config looks like this:

;; denote
(require 'denote)
(require 'denote-org-dblock)
(setq denote-directory (expand-file-name "~/Dropbox/org/denote"))
(require 'denote-journal-extras)
;; Set to nil to prompt for title
(setq denote-journal-extras-title-format nil)

In the meantime, there's a straightforward workaround:

  • (setq denote-journal-extras-title-format 'day-date-month-year)
  • edit file front matter
  • denote-rename-file-using-front-matter

from denote.

protesilaos avatar protesilaos commented on July 28, 2024

Oh, this is strange! Could it be that there was some old code kept around during your session and the new one will take effect upon restart? I can no longer reproduce the error: it works as expected on my end.

Screenshots below.

Ordinary prompt for title, with current date as the default value

2023-10-16_16:29:46_1117x517

User input at the prompt

2023-10-16_16:29:55_1117x517

The resulting buffer

2023-10-16_16:30:10_1117x517

from denote.

tjstankus avatar tjstankus commented on July 28, 2024

Thanks @protesilaos! I'm still seeing the issue. Again, not a big deal because I can work around it like I mentioned. And it may very well be something in my config. I recorded this video showing the issue on my machine - maybe it will help. Thank you for your generous work on this package!

from denote.

protesilaos avatar protesilaos commented on July 28, 2024

Thank you @tjstankus! I could not reproduce your issue, though I still rewrote the helper function. Here is its current implementation:

(defun denote-journal-extras-daily--title-format ()
  "Return `denote-journal-extras-title-format' or prompt for title."
  (format-time-string
   (if (and denote-journal-extras-title-format
            (stringp denote-journal-extras-title-format))
       denote-journal-extras-title-format
     (pcase denote-journal-extras-title-format
       ('day "%A")
       ('day-date-month-year "%A %e %B %Y")
       ('day-date-month-year-24h "%A %e %B %Y %H:%M")
       ('day-date-month-year-12h "%A %e %B %Y %I:%M %^p")
       (_ (denote-title-prompt (format-time-string "%F")))))))

I also wrote this test for it:

(ert-deftest denote-test--denote-journal-extras-daily--title-format ()
  "Make sure that `denote-journal-extras-daily--title-format' yields the desired format."
  (should (and
           ;; These three should prompt, but I am here treating the
           ;; prompt as if already returned a string.  The test for
           ;; the `denote-title-prompt' can be separate.
           (stringp
            (cl-letf (((symbol-function 'denote-title-prompt) #'identity)
                      (denote-journal-extras-title-format nil))
              (denote-journal-extras-daily--title-format)))

           (stringp
            (cl-letf (((symbol-function 'denote-title-prompt) #'identity)
                      (denote-journal-extras-title-format t))
              (denote-journal-extras-daily--title-format)))

           (stringp
            (cl-letf (((symbol-function 'denote-title-prompt) #'identity)
                      (denote-journal-extras-title-format :some-arbitrary-keyword))
              (denote-journal-extras-daily--title-format)))

           ;; And these return the following values
           (string-match-p
            "\\<.*?\\>"
            (let ((denote-journal-extras-title-format 'day))
              (denote-journal-extras-daily--title-format)))

           (string-match-p
            "\\<.*?\\> [0-9]\\{,2\\} \\<.*?\\> [0-9]\\{,4\\}"
            (let ((denote-journal-extras-title-format 'day-date-month-year))
              (denote-journal-extras-daily--title-format)))

           (string-match-p
            "\\<.*?\\> [0-9]\\{,2\\} \\<.*?\\> [0-9]\\{,4\\} [0-9]\\{,2\\}:[0-9]\\{,2\\} \\<.*?\\>"
            (let ((denote-journal-extras-title-format 'day-date-month-year-12h))
              (denote-journal-extras-daily--title-format)))

           (string-match-p
            "\\<.*?\\> [0-9]\\{,2\\} \\<.*?\\> [0-9]\\{,4\\} [0-9]\\{,2\\}:[0-9]\\{,2\\}"
            (let ((denote-journal-extras-title-format 'day-date-month-year-24h))
              (denote-journal-extras-daily--title-format))))))

You can try the test by checking if the following returns a non-nil value (a 0 still counts as non-nil):

(and
 ;; These three should prompt, but I am here treating the
 ;; prompt as if already returned a string.  The test for
 ;; the `denote-title-prompt' can be separate.
 (stringp
  (cl-letf (((symbol-function 'denote-title-prompt) #'identity)
            (denote-journal-extras-title-format nil))
    (denote-journal-extras-daily--title-format)))

 (stringp
  (cl-letf (((symbol-function 'denote-title-prompt) #'identity)
            (denote-journal-extras-title-format t))
    (denote-journal-extras-daily--title-format)))

 (stringp
  (cl-letf (((symbol-function 'denote-title-prompt) #'identity)
            (denote-journal-extras-title-format :some-arbitrary-keyword))
    (denote-journal-extras-daily--title-format)))

 ;; And these return the following values
 (string-match-p
  "\\<.*?\\>"
  (let ((denote-journal-extras-title-format 'day))
    (denote-journal-extras-daily--title-format)))

 (string-match-p
  "\\<.*?\\> [0-9]\\{,2\\} \\<.*?\\> [0-9]\\{,4\\}"
  (let ((denote-journal-extras-title-format 'day-date-month-year))
    (denote-journal-extras-daily--title-format)))

 (string-match-p
  "\\<.*?\\> [0-9]\\{,2\\} \\<.*?\\> [0-9]\\{,4\\} [0-9]\\{,2\\}:[0-9]\\{,2\\} \\<.*?\\>"
  (let ((denote-journal-extras-title-format 'day-date-month-year-12h))
    (denote-journal-extras-daily--title-format)))

 (string-match-p
  "\\<.*?\\> [0-9]\\{,2\\} \\<.*?\\> [0-9]\\{,4\\} [0-9]\\{,2\\}:[0-9]\\{,2\\}"
  (let ((denote-journal-extras-title-format 'day-date-month-year-24h))
    (denote-journal-extras-daily--title-format))))

from denote.

tjstankus avatar tjstankus commented on July 28, 2024

@protesilaos I updated again and it works - thank you!

from denote.

protesilaos avatar protesilaos commented on July 28, 2024

Very well! We can safely close this. Thank you!

from denote.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.