From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: [NonGNU Elpa] New package: ETT Date: Wed, 03 May 2023 16:41:21 +0000 Message-ID: <87a5ylcqq6.fsf@posteo.net> References: <86ild9bgel.fsf@disroot.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33143"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: John Task Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 03 18:42:16 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 1puFYW-0008Ra-CK for ged-emacs-devel@m.gmane-mx.org; Wed, 03 May 2023 18:42:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puFXl-00064V-TJ; Wed, 03 May 2023 12:41:29 -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 1puFXk-0005w6-5l for emacs-devel@gnu.org; Wed, 03 May 2023 12:41:28 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puFXg-0005lv-PM for emacs-devel@gnu.org; Wed, 03 May 2023 12:41:27 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 3C44A24030B for ; Wed, 3 May 2023 18:41:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1683132082; bh=9EKhF7MsP5lIOC0eSj27S0SY2XexYFjCYM9hkUNmTwE=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=F68HtVOPSYVVOsmB1yU99V6OdkYbqp/MeBwu0TYQxc9hm4Di68RDlMJvvtwH3SWQb HayvZ2MIQxAslyaVJAEPU2cJIhFpuj0VDmD6tW7Ek7nqr54KOfZ3vRz3YPb+ZU1EYD LOO3AcMOhNbuDhCh1K+jBGy6mH/FasgoZXOKgVEC3Nl+AK/I7B80ZYL2/IO5EGilpG NA3cbyr9XHFq06VWGl1SaR/4oQrwurTfYxNFgOAmbAs/DL43NqDODaZJtr0KbOnmUx c7GvskYERKD02U90hxL6DAA8UKWnrUy9DUptPoqaZhTYaMemwo26l34xRSH1GcsWsb NkVrVJnFZE/3w== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QBN4d5DMBz6tm4; Wed, 3 May 2023 18:41:21 +0200 (CEST) In-Reply-To: <86ild9bgel.fsf@disroot.org> (John Task's message of "Wed, 03 May 2023 12:02:57 -0300") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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-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:305788 Archived-At: John Task writes: >> (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. If that is so, I would explain that in the documentation string, but what I wonder is why if condition is needed. All you basically do is avoid converting num1 to a float, and the result remains a integer, in some cases. >> (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. While this will calculate the values in constant time, (list (floor time 60) (% time 60)) a loop will always take more iterations depending on the value of the input: (let ((hr 0)) (while (>= time 60) (setq hr (1+ hr) time (- time 60))) (list hr time)) >> (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. FWIW i even hesitated in bringing this up, because as you say the regular expressions are currently modest in complexity. >> +(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. Right, that was a typo. All I provide is faulty static analysis ^^ >> (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. OK, I didn't know about that, then this is fine.