From: John Task <q01@disroot.org>
To: Philip Kaludercic <philipk@posteo.net>
Cc: emacs-devel@gnu.org
Subject: Re: [NonGNU Elpa] New package: ETT
Date: Wed, 03 May 2023 12:02:57 -0300 [thread overview]
Message-ID: <86ild9bgel.fsf@disroot.org> (raw)
In-Reply-To: 87mt2m9cbk.fsf@posteo.net
Thank you very much for the comments.
> I would track the ignored files in a .elpaignore file that would look
> something like this
OK.
> -(defcustom ett-file (concat user-emacs-directory "tracks.ett")
> +(defcustom ett-file (locate-user-emacs-file "tracks.ett")
> "File for storing ETT tracks."
> :type '(file))
OK.
> -(defcustom ett-graph-icon "│"
> +(defcustom ett-graph-icon ?│
> "Icon used for building ETT graphs.
> It must be a single char string."
> - :type '(string))
> + :type 'character)
>
> (defface ett-heading
> '((((class color) (min-colors 88) (background light))
> @@ -170,7 +170,7 @@ It must be a single char string."
> (list "^\\(Less time .*\\): " '(1 'underline))
> (list "^\\(Tags report\\):$" '(1 'underline))
> (list "^\\(Pending goals\\):$" '(1 'underline))
> - (list (concat ett-graph-icon "+") '(0 'ett-separator-face)))
> + (list (concat (string ett-graph-icon) "+") '(0 'ett-separator-face)))
> "Keywords for syntax highlighting on ETT report buffer.")
I should have thought about that myself, I forgot the string function
:)
> (defvar ett-items-internal nil)
> @@ -269,41 +269,36 @@ Here are some translations (*starred* values are current at the time):
> 3-2 ---> 03-02-*23*
> 03 ---> 03-*02*-*23*
> 3 ---> 03-*02*-*23*"
> - (pcase (length date)
> - ;; DD-MM-YY
> - (8 date)
> - ;; DD-MM
> - (5 (setq date (concat date (format-time-string "-%y"))))
> - ;; DD
> - (2 (setq date (concat date (format-time-string "-%m-%y"))))
> - ;; D
> - (1 (setq date (concat "0" date (format-time-string "-%m-%y"))))
> - ;; DD-M
> - (4
> - (setq date
> - ;; Or D-MM?
> - (pcase (string-search "0" date)
> - (2 (concat "0" date (format-time-string "-%y")))
> - (_ (concat
> + (setq date
> + (pcase (length date)
> + ;; DD-MM-YY
> + (8 date)
> + ;; DD-MM
> + (5 (concat date (format-time-string "-%y")))
> + ;; DD
> + (2 (concat date (format-time-string "-%m-%y")))
> + ;; D
> + (1 (concat "0" date (format-time-string "-%m-%y")))
> + ;; DD-M
> + (4
> + ;; Or D-MM?
> + (pcase (string-search "0" date)
> + (2 (concat "0" date (format-time-string "-%y")))
> + (_ (concat
> (replace-regexp-in-string "-\\(.*\\)" "-0\\1" date)
> - (format-time-string "-%y"))))))
> - ;; D-M
> - (3 (setq date
> - (concat "0" (replace-regexp-in-string "-\\(.*\\)" "-0\\1" date)
> - (format-time-string "-%y"))))
> - ;; D-MM-YY
> - (7 (setq date
> - ;; Or DD-M-YY?
> - (pcase (string-search "0" date)
> - (2 (concat "0" date))
> - (_ (concat
> - (replace-regexp-in-string "-\\(.*\\)-" "-0\\1-" date))))))
> - ;; D-M-YY (who writes like that?)
> - (6 (setq date
> - (concat "0"
> - (replace-regexp-in-string "-\\(.*\\)-" "-0\\1-" date)))))
> - ;; Return date
> - date)
> + (format-time-string "-%y")))))
> + ;; D-M
> + (3 (concat "0" (replace-regexp-in-string "-\\(.*\\)" "-0\\1" date)
> + (format-time-string "-%y")))
> + ;; D-MM-YY
> + (7 ;; Or DD-M-YY?
> + (pcase (string-search "0" date)
> + (2 (concat "0" date))
> + (_ (concat
> + (replace-regexp-in-string "-\\(.*\\)-" "-0\\1-" date)))))
> + ;; D-M-YY (who writes like that?)
> + (6 (concat "0"
> + (replace-regexp-in-string "-\\(.*\\)-" "-0\\1-" date))))))
This is indeed better, thanks.
> (defun ett-do-division (num1 num2)
> - "Divide NUM1 between NUM2."
> + "Divide NUM1 between NUM2." ;can you explain why this is needed?
> (if (/= (% num1 num2) 0)
> (/ (float num1) num2)
> (/ num1 num2)))
I need the extra precision for various functions. (/ 12 7) gives me
1, while (ett-do-division 12 7) gives me 1.7142857142857142.
> (insert
> (mapconcat #'concat (make-list (- col (current-column)) " ") "")))
> (ett-insert-rectangle
> - (make-list graph-f ett-graph-icon)))
> + (make-list graph-f (string ett-graph-icon))))
> (setq list (cdr list)
OK.
> (defun ett-prettify-time (time)
> "Return a prettified string for TIME."
> (let ((hr 0))
> - (while (>= time 60)
> + (while (>= time 60) ;the loop here shouldn't be necessary, you can calculate the same thing using remainder and floor
> (setq hr (1+ hr)
> time (- time 60)))
I'll look into that. Is there any reason why I would need to avoid
that loop? The code just works for now.
> (save-excursion
> ;; Sort items
> ;; We need to do it in two steps because it's somehow complicated
> - (sort-regexp-fields t "^.*$" "\\(:[0-9]+\\)" (point-min) (point-max))
> + (sort-regexp-fields t "^.*$" "\\(:[0-9]+\\)" (point-min) (point-max)) ;have you considered using rx?
> (sort-regexp-fields t "^.*$" "\\([0-9]+:\\)" (point-min) (point-max))
> ;; We now align
> (align-regexp
I have considered it, but while my regexps are weird, they are
still readable for now. Maybe I'll reconsider it.
> +(defvar ett-view-mode-map
> + (let ((map (make-sparse-keymap)))
> + (define-key map (kbd "C-c C-c") #'ett-add-track)
> + (define-key map (kbd "SPC") #'ett-space-dwim)
> + map))
I think you mean just ett-mode-map. In that case, OK.
> (define-derived-mode ett-mode text-mode "ETT"
> "Major mode for editing ETT based texts."
> (setq font-lock-defaults '(ett-font-lock-keywords t))
> - (setq-local outline-regexp "[0-9]+-[0-9]+-[0-9]+")
> + (setq-local outline-regexp "[0-9]+-[0-9]+-[0-9]+") ;does this need to start with a ^
> ;; show-paren-mode can be somehow annoying here
> (show-paren-local-mode -1))
Documentation of the variable says it isn't necessary, and it worked
as is on my tests, but I'm not an expert.
> +(defvar ett-view-mode-map
> + (let ((map (make-sparse-keymap)))
> + (define-key map (kbd "q") #'bury-buffer)
> + (define-key map (kbd "SPC") #'ett-choose-view)
> + (define-key map (kbd "<up>") #'scroll-down-command)
> + (define-key map (kbd "<down>") #'scroll-up-command)
> + map))
OK.
> -(define-key ett-view-mode-map (kbd "q") #'bury-buffer)
> -(define-key ett-view-mode-map (kbd "SPC") #'ett-choose-view)
> -(define-key ett-view-mode-map (kbd "<up>") #'scroll-down-command)
> -(define-key ett-view-mode-map (kbd "<down>") #'scroll-up-command)
> -(define-key ett-mode-map (kbd "C-c C-c") #'ett-add-track)
> -(define-key ett-mode-map (kbd "SPC") #'ett-space-dwim)
> -
> ;;;###autoload
> -(add-to-list 'auto-mode-alist (cons (purecopy "\\.ett\\'") 'ett-mode))
> +(add-to-list 'auto-mode-alist '("\\.ett\\'" . ett-mode))
OK.
> Oh an by the way, it seems possible to reduce the minimum version of
> Emacs to at least 26 using Compat
> (https://elpa.gnu.org/packages/compat.html). Would you be interested in
> that?
Yes, I plan to work on backward compatibility once the code is well
tested. You know, better to see if it works on a version before
porting it to other ones :)
Thanks again. Best regards.
next reply other threads:[~2023-05-03 15:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 15:02 John Task [this message]
2023-05-03 16:41 ` [NonGNU Elpa] New package: ETT Philip Kaludercic
-- strict thread matches above, loose matches on Subject: below --
2023-05-03 18:06 John Task
2023-05-03 17:14 John Task
2023-05-03 18:05 ` Eli Zaretskii
2023-05-03 15:29 John Task
2023-05-03 16:57 ` Sam Steingold
2023-05-03 14:07 John Task
2023-05-03 15:55 ` Eli Zaretskii
2023-05-02 21:21 John Task
2023-05-03 6:08 ` Philip Kaludercic
2023-05-03 6:11 ` Philip Kaludercic
2023-05-03 7:12 ` Yuri Khan
2023-05-03 11:12 ` Eli Zaretskii
2023-03-01 18:17 John Task
2023-03-01 17:46 John Task
2023-03-02 4:33 ` Richard Stallman
2023-03-02 10:08 ` Holger Schurig
2023-03-02 14:50 ` q01
2023-03-02 15:55 ` John Task
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86ild9bgel.fsf@disroot.org \
--to=q01@disroot.org \
--cc=emacs-devel@gnu.org \
--cc=philipk@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.