From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: John Task Newsgroups: gmane.emacs.devel Subject: Re: [NonGNU Elpa] New package: ETT Date: Wed, 03 May 2023 12:02:57 -0300 Message-ID: <86ild9bgel.fsf@disroot.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7544"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 03 17:50:47 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1puEkh-0001hT-6C for ged-emacs-devel@m.gmane-mx.org; Wed, 03 May 2023 17:50:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puEjt-0005YA-O4; Wed, 03 May 2023 11:49:57 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puE6X-0006My-SB for emacs-devel@gnu.org; Wed, 03 May 2023 11:09:18 -0400 Original-Received: from knopi.disroot.org ([178.21.23.139]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puE6U-0003rf-Us for emacs-devel@gnu.org; Wed, 03 May 2023 11:09:17 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 9267D401BA; Wed, 3 May 2023 17:09:11 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Original-Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9PkYsz6uyQip; Wed, 3 May 2023 17:09:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1683126549; bh=Yre2LLQpgloXIRAt8o4HqpuDiEzhdWoAOkjqNsyozm4=; h=From:To:Cc:Subject:In-Reply-To:Date; b=F5DAkntfu6zjBt5bKDP58/wB+MU9RqXE7tlEkcI6r7HhPRu2hSiaFAkrnfVVIiNs4 omUJOECYCtZUtR4C4rSKSGteMbhv0XHtUSx0wP9J1Ri+9nT6muXw7IDLDu3SaWVYxU zGCDapdR1HjOMYnrLQpE01M/fy3N0SeIQ9fjARvb7fjYEpAP7C1QRa4grI3G+/kwub lUHvVly4Hu15hYVB2JqoaPYpZSkPGUHxw2W7FM/OtjkN3Ag1X57jPSe8RQnRuTSYPo tobH7b0x0eaopAPBKFSFm9mzfHcj4FFCRROmKmByZLYW/yX2j7MURSGnU6TP+Hg/pa xS9d6gXokJKRg== In-Reply-To: 87mt2m9cbk.fsf@posteo.net Received-SPF: pass client-ip=178.21.23.139; envelope-from=q01@disroot.org; helo=knopi.disroot.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 03 May 2023 11:49:55 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:305782 Archived-At: 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. =20 > -(defcustom ett-graph-icon "=E2=94=82" > +(defcustom ett-graph-icon ?=E2=94=82 > "Icon used for building ETT graphs. > It must be a single char string." > - :type '(string)) > + :type 'character) >=20=20 > (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-fa= ce))) > "Keywords for syntax highlighting on ETT report buffer.") I should have thought about that myself, I forgot the string function :) =20 > (defvar ett-items-internal nil) > @@ -269,41 +269,36 @@ Here are some translations (*starred* values are cu= rrent 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" d= ate) > - (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-" dat= e))))) > - ;; 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 (/=3D (% 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 (>=3D time 60) > + (while (>=3D time 60) ;the loop here shouldn't be necessary, you c= an 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-ma= x)) > + (sort-regexp-fields t "^.*$" "\\(:[0-9]+\\)" (point-min) (point-ma= x)) ;have you considered using rx? > (sort-regexp-fields t "^.*$" "\\([0-9]+:\\)" (point-min) (point-ma= x)) > ;; 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 "") #'scroll-down-command) > + (define-key map (kbd "") #'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 "") #'scroll-down-command) > -(define-key ett-view-mode-map (kbd "") #'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.