From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Akib Azmain Turja Newsgroups: gmane.emacs.devel Subject: Re: [NonGNU ELPA] 11 new packages! Date: Tue, 29 Nov 2022 01:07:25 +0600 Message-ID: <87sfi2vqxe.fsf@disroot.org> References: <87r0y6ug9z.fsf@disroot.org> <87y1sct2hp.fsf@posteo.net> <87k03vf5m8.fsf@disroot.org> <87edu2narn.fsf@posteo.net> <8735aieqtr.fsf@disroot.org> <87cz9mlq3o.fsf@posteo.net> <875yfdd5ad.fsf@disroot.org> <87wn7hh438.fsf@posteo.net> <87sfi5h3ne.fsf@posteo.net> <874julpgi4.fsf@disroot.org> <87v8n04o4b.fsf@posteo.net> <87cz98nxah.fsf@disroot.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25759"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Emacs Developer List To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 28 20:34:05 2022 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 1ozjtE-0006Rs-0n for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Nov 2022 20:34:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozjsY-0005Um-Ug; Mon, 28 Nov 2022 14:33:22 -0500 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 1ozjsU-0005Tm-Th for emacs-devel@gnu.org; Mon, 28 Nov 2022 14:33:18 -0500 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 1ozjsR-0001dA-72 for emacs-devel@gnu.org; Mon, 28 Nov 2022 14:33:18 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 6C0B140E43; Mon, 28 Nov 2022 20:33:09 +0100 (CET) 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 9KL0X4MBG4wC; Mon, 28 Nov 2022 20:33:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1669663980; bh=9ubQdsXMdYxMPDRzglu57zrEjvsaMcLwFmz/REwQG3w=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=NZdgLNjELJuwwSWtlE5RWAtXlQFMrVUx0ADbQc61u5ZXgJV4SItInVSbSJ4aa5Odg Ipp4I55FyEQ+E2Zah+puuVTzCa4asgg5Gcbe7Clq6PX5YjE1OJPG1W0Nnc3G7+Em5n 73E0LQ913j5bE6lOyhCJwGZFzF682Azkq3KiWC0idAA5zJnryO9DN5i/q9zAMYZuri zMC0V8d6BC2QDkLv9TAVOTqIgMb1jOy2eX3DqyWXeRheINyRmr3f2sRmsPx2AKBmUT gd8QJsztQyskv0Z+mrJsFKCkFn1AM7govKZ3RoqBsvfWQuInxm8ZqMBnfZtXSc1GUe I10/n6BZDMAsQ== In-Reply-To: <87cz98nxah.fsf@disroot.org> (Akib Azmain Turja's message of "Sun, 27 Nov 2022 23:04:54 +0600") Received-SPF: pass client-ip=178.21.23.139; envelope-from=akib@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 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:300682 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Akib Azmain Turja writes: > Philip Kaludercic writes: [...] >> @@ -445,6 +448,10 @@ If your process is choking on big inputs, try lower= ing the value." >>=20=20 >> (put 'eat-term-color-bright-white 'face-alias 'eat-term-color-15) >>=20=20 >> +;; Perhaps you could automatically generate this block and make it >> +;; more maintainable? `defface' is just a wrapper around >> +;; `custom-declare-face', so you could invoke that in a loop that >> +;; defines all the faces. >> (defface eat-term-color-16 >> '((t :foreground "#000000" :background "#000000")) >> "Face used to render text with 16th color of 256 color palette." > > Yes, you are right. I didn't know this at the time of writing that > piece of code. TODO. [...] >> @@ -1775,7 +1785,7 @@ Treat LINE FEED (?\\n) as the line delimiter." >> ;; Move to the beginning of line, record the point, and return that >> ;; point and the distance of that point from current line in lines. >> (save-excursion >> - (let* ((moved (eat--t-goto-eol n))) >> + (let ((moved (eat--t-goto-eol n))) >> (cons (point) moved)))) >>=20=20 >> (defun eat--t-col-motion (n) > > I think I do that very often. TODO. (A reminder for me. I'll do any > change you suggested later, as I'm working to fix a bug in Eat.) Done. > >> @@ -1823,9 +1833,9 @@ Assume all characters occupy a single column." >> (eat--t-col-motion n)) >>=20=20 >> (defun eat--t-repeated-insert (c n &optional face) >> - "Insert C, N times. >> + "Insert character C, N times. >>=20=20 >> -C is a character. FACE is the face to use, or nil." >> +FACE is the face to use, or nil." >> (let ((str (make-string n c))) >> (insert (if face (propertize str 'face face) str)))) >>=20=20 > Done. [...] >> (defun eat--t-cur-left (&optional n) >> @@ -2297,6 +2308,7 @@ of range, place cursor at the edge of display." >> "Change character set to CHARSET. >>=20=20 >> CHARSET should be one of `g0', `g1', `g2' and `g3'." >> + (cl-assert (memq charset '(g0 g1 g2 g3))) >> (setf (car (eat--t-term-charset eat--t-term)) charset)) >>=20=20 > > Thanks, that assertion should be there. TODO. > Done. >> (defun eat--t-write (str) >> @@ -2319,6 +2331,7 @@ CHARSET should be one of `g0', `g1', `g2' and `g3'= ." >> ('dec-line-drawing >> (let ((s (copy-sequence str))) >> (dotimes (i (length s)) >> + ;; Perhaps you should pull out the alist into a `defco= nst' >> (let ((replacement (alist-get (aref s i) >> '((?+ . ?=E2=86=92) >> (?, . ?=E2=86=90) > > Yes, I'm planning to use a hash-table (made with eval-when-compile). > TODO. > Done, with a lot of changes in that function. [...] >> @@ -2561,7 +2574,7 @@ N defaults to 0. When N is 0, erase cursor to end= of line. When N is >> (let* ((disp (eat--t-term-display eat--t-term)) >> (face (eat--t-term-face eat--t-term)) >> (cursor (eat--t-disp-cursor disp))) >> - (pcase n >> + (pcase-exhaustive n ; >> ((or 0 'nil (pred (< 2))) >> ;; Delete cursor position (inclusive) to end of line. >> (delete-region (point) (car (eat--t-eol))) >> @@ -2619,7 +2632,7 @@ to (1, 1). When N is 3, also erase the scrollback= ." >> (let* ((disp (eat--t-term-display eat--t-term)) >> (face (eat--t-term-face eat--t-term)) >> (cursor (eat--t-disp-cursor disp))) >> - (pcase n >> + (pcase-exhaustive n >> ((or 0 'nil (pred (< 3))) >> ;; Delete from cursor position (inclusive) to end of terminal. >> (delete-region (point) (point-max)) > > What's... Checking docs... Oh, thanks, that'll trigger an error in > case of no match. TODO. > Done. [...] >> @@ -2906,18 +2919,16 @@ position." >> ;; on failure. >> (when (and (<=3D scroll-begin (eat--t-cur-y cursor) scroll-end) >> (not (zerop n))) >> + (eat--t-goto-bol) >> + (eat--t-repeated-insert ?\ (1- (eat--t-cur-x cursor)) >> + (and (eat--t-face-bg face) >> + (eat--t-face-face face))) >> (goto-char >> - (prog1 >> - (progn >> - ;; This function doesn't move the cursor, but pushes all >> - ;; the line below and including current line. So to keep >> - ;; the cursor unmoved, go to the beginning of line and >> - ;; insert enough spaces to not move the cursor. >> - (eat--t-goto-bol) >> - (eat--t-repeated-insert ?\ (1- (eat--t-cur-x cursor)) >> - (and (eat--t-face-bg face) >> - (eat--t-face-face face))) >> - (point)) >> + ;; This function doesn't move the cursor, but pushes all >> + ;; the line below and including current line. So to keep >> + ;; the cursor unmoved, go to the beginning of line and >> + ;; insert enough spaces to not move the cursor. >> + (prog1 (point) >> ;; Insert N lines. >> (if (not (eat--t-face-bg face)) >> (eat--t-repeated-insert ?\n n) > > I really wonder why, why I wrote the code like that? > Fixed. >> @@ -3189,7 +3200,8 @@ TOP defaults to 1 and BOTTOM defaults to the heigh= t of the display." >> nil t))))) >> ;; Update face according to the attributes. >> (setf (eat--t-face-face face) >> - `(,@(when-let ((fg (or (if (eat--t-face-conceal face) >> + ;; `while' is for side-effects, `and' is for expressions >> + `(,@(and-let* ((fg (or (if (eat--t-face-conceal face) >> (eat--t-face-bg face) >> (eat--t-face-fg face)) >> (cond >> @@ -3201,31 +3213,31 @@ TOP defaults to 1 and BOTTOM defaults to the hei= ght of the display." >> :background >> :foreground) >> fg)) >> - ,@(when-let ((bg (or (eat--t-face-bg face) >> + ,@(and-let* ((bg (or (eat--t-face-bg face) >> (and (eat--t-face-inverse face) >> (face-background 'default))))) >> (list (if (eat--t-face-inverse face) >> :foreground >> :background) >> bg)) >> - ,@(when-let ((underline (eat--t-face-underline face))) >> + ,@(and-let* ((underline (eat--t-face-underline face))) >> (list >> :underline >> (list :color (eat--t-face-underline-color face) >> :style underline))) >> - ,@(when-let ((crossed (eat--t-face-crossed face))) >> + ,@(and-let* ((crossed (eat--t-face-crossed face))) >> ;; REVIEW: How about colors? No terminal supports >> ;; crossed attribute with colors, so we'll need to be >> ;; creative to add the feature. >> `(:strike-through t)) >> :inherit >> - (,@(when-let ((intensity (eat--t-face-intensity face))) >> + (,@(and-let* ((intensity (eat--t-face-intensity face))) >> (list intensity)) >> - ,@(when-let ((italic (eat--t-face-italic face))) >> + ,@(and-let* ((italic (eat--t-face-italic face))) >> (cl-assert (1value (eq (1value italic) >> 'eat-term-italic))) >> (list (1value italic))) >> - ,@(when-let ((blink (eat--t-face-blink face))) >> + ,@(and-let* ((blink (eat--t-face-blink face))) >> (list blink)) >> ,(eat--t-face-font face)))))) >>=20=20 > > Did you mean "when" instead of "while"? TODO. > Done. >> @@ -3261,7 +3273,7 @@ MODE should be one of nil and `x10', `normal', `bu= tton-event', >> (setf (eat--t-term-mouse-pressed eat--t-term) nil)) >> ;; Inform the UI. >> (funcall (eat--t-term-grab-mouse-fn eat--t-term) eat--t-term >> - (pcase mode >> + (pcase-exhaustive mode >> ('x10 :click) >> ('normal :modifier-click) >> ('button-event :drag) > > TODO. > Done. [...] >> @@ -3788,17 +3802,15 @@ DATA is the selection data encoded in base64." >> (rx ?\\)) >> output index))) >> (if (not match) >> - (progn >> - ;; Not found, store the text to process it later when >> - ;; we get the end of string. >> - (setf (eat--t-term-parser-state eat--t-term) >> - `(,state ,(concat buf (substring output >> - index)))) >> - (setq index (length output))) >> + ;; Not found, store the text to process it later when >> + ;; we get the end of string. >> + (setf (eat--t-term-parser-state eat--t-term) >> + `(,state ,(concat buf (substring output >> + index))) >> + index (length output)) >> ;; Matched! Get the string from the output and previous >> ;; runs. >> - (let ((str (concat buf (substring output index >> - match)))) >> + (let ((str (concat buf (substring output index match)))) >> (setq index (match-end 0)) >> ;; Is it really the end of string? >> (if (and (=3D (aref output match) ?\\) > > Somehow I prefer to use one setq for each variable. Is setting multiple > at once faster? Benchmarking with "benchmark"... Yes, about 1.5 times. > TODO. > Done, but I didn't combine setf and setq, only two setq's or two setf's. [...] >> @@ -3985,6 +3997,10 @@ DATA is the selection data encoded in base64." >> "Setup the environment for TERMINAL and eval BODY in it." >> (declare (indent 1)) >> `(let ((eat--t-term ,terminal)) >> + ;; This won't change much here, because the next line would >> + ;; trigger a similar exception, but there might be some other >> + ;; place where an explicit check could be of use. >> + (cl-check-type eat--t-term eat--t-term) >> (with-current-buffer (eat--t-term-buffer eat--t-term) >> (save-excursion >> (save-restriction > > Hmm, it's a good idea on check early. > I didn't find any such spot... [...] >> @@ -4399,7 +4416,7 @@ client process may get confused." >> (let ((ch (pcase (event-convert-list >> (append (remq 'meta mods) >> (list base))) >> - (?\C-\ ?\C-@) >> + (?\C-\s ?\C-@) >> (?\C-/ ?\C-?) >> (?\C-- ?\C-_) >> (c c)))) > > OK, now I must admit I missed this. TODO. > Done. >> @@ -4608,9 +4625,9 @@ keywords: >> EXCEPTIONS is a list of key sequences to not bind. Don't use >> \"M-...\" key sequences in EXCEPTIONS, use \"ESC ...\" instead." >> (let ((map (make-sparse-keymap))) >> - (cl-labels ((bind (key) >> - (unless (member key exceptions) >> - (define-key map key input-command)))) >> + (cl-flet ((bind (key) >> + (unless (member key exceptions) >> + (define-key map key input-command)))) >> (when (memq :ascii categories) >> ;; Bind ASCII and self-insertable characters except ESC and >> ;; DEL. > > Thanks. > Done. >> @@ -4618,7 +4635,7 @@ EXCEPTIONS is a list of key sequences to not bind.= Don't use >> (cl-loop >> for i from ?\C-@ to ?~ >> do (unless (=3D i meta-prefix-char) >> - (bind `[,i]))) >> + (bind (vector i)))) >> ;; Bind `backspace', `delete', `deletechar', and all modified >> ;; variants. >> (dolist (key '( backspace C-backspace > > Again a useless backquote usage... > Done. >> @@ -4780,11 +4797,12 @@ return \"eat-color\", otherwise return \"eat-mon= o\"." >> (defvar eat--fast-blink-timer nil >> "Timer for blinking rapidly blinking text.") >>=20=20 >> +(declare-function face-remap-add-relative "face-remap" >> + (face &rest specs)) >> +(declare-function face-remap-remove-relative "face-remap" (cookie)) >> + >> (defun eat--flip-slow-blink-state () >> "Flip the state of slowly blinking text." >> - (declare-function face-remap-add-relative "face-remap" >> - (face &rest specs)) >> - (declare-function face-remap-remove-relative "face-remap" (cookie)) >> (face-remap-remove-relative eat--slow-blink-remap) >> (setq eat--slow-blink-remap >> (face-remap-add-relative > > TODO. > >> @@ -4794,9 +4812,6 @@ return \"eat-color\", otherwise return \"eat-mono\= "." >>=20=20 >> (defun eat--flip-fast-blink-state () >> "Flip the state of rapidly blinking text." >> - (declare-function face-remap-add-relative "face-remap" >> - (face &rest specs)) >> - (declare-function face-remap-remove-relative "face-remap" (cookie)) >> (face-remap-remove-relative eat--fast-blink-remap) >> (setq eat--fast-blink-remap >> (face-remap-add-relative Both, done. >> @@ -4853,6 +4868,7 @@ return \"eat-color\", otherwise return \"eat-mono\= "." >> (face-remap-remove-relative eat--fast-blink-remap) >> (remove-hook 'pre-command-hook #'eat--blink-stop-timers t) >> (remove-hook 'post-command-hook #'eat--blink-start-timers t) >> + ;; I think `mapc' comes in nicely here >> (kill-local-variable 'eat--slow-blink-state) >> (kill-local-variable 'eat--fast-blink-state) >> (kill-local-variable 'eat--slow-blink-remap) > > Yes. TODO. > Done. [...] >> @@ -5216,13 +5233,13 @@ ARG is passed to `yank-pop', which see." >> (defun eat-semi-char-mode () >> "Switch to semi-char mode." >> (interactive) >> - (if (not eat--terminal) >> - (error "Process not running") >> - (setq buffer-read-only nil) >> - (eat--char-mode -1) >> - (eat--semi-char-mode +1) >> - (eat--grab-mouse nil eat--mouse-grabbing-type) >> - (force-mode-line-update))) >> + (unless eat--terminal >> + (error "Process not running")) >> + (setq buffer-read-only nil) >> + (eat--char-mode -1) >> + (eat--semi-char-mode +1) >> + (eat--grab-mouse nil eat--mouse-grabbing-type) >> + (force-mode-line-update)) >>=20=20 > > Thanks. TODO. > Done. >> (defun eat-char-mode () >> "Switch to char mode." >> @@ -5302,7 +5319,7 @@ selection, or nil if none." >>=20=20 >> (defun eat--bell (_) >> "Ring the bell." >> - (beep t)) >> + (ding t)) >>=20=20 > > Any difference? Anyway, TODO. > Done. >> >> ;;;;; Major Mode. >> @@ -5340,6 +5357,7 @@ END if it's safe to do so." >> (define-derived-mode eat-mode fundamental-mode "Eat" >> "Major mode for Eat." >> :group 'eat-ui >> + ;; You can abbreviate parts of the definition with `setq-local'. >> (make-local-variable 'buffer-read-only) >> (make-local-variable 'buffer-undo-list) >> (make-local-variable 'filter-buffer-substring-function) >> @@ -5372,8 +5390,8 @@ END if it's safe to do so." >> (:propertize >> "semi-char" >> help-echo >> - ,(concat "mouse-1: Switch to char mode, " >> - "mouse-3: Switch to emacs mode") >> + ,"mouse-1: Switch to char mode, \ >> +mouse-3: Switch to emacs mode" >> mouse-face mode-line-highlight >> local-map >> (keymap > > TODO. > Done. [...] >> @@ -5974,6 +5996,8 @@ modify its argument to change the filter, the sent= inel and invoke >> (expand-file-name command)) >> args)))) >> (apply make-process plist) >> + ;; `plist-put' is not destructive, you need to store the >> + ;; return value. >> (plist-put plist :filter #'eat--eshell-filter) >> (plist-put plist :sentinel #'eat--eshell-sentinel) >> (plist-put > > Thanks, I'll use setf instead. TODO. > Done. >> @@ -6328,7 +6352,7 @@ FN, `eat-exec', which see." >> (push (cons var (symbol-value var)) variables))) >> (with-current-buffer buf >> (lisp-data-mode) >> - (insert ";; -*- lisp-data -*-\n") >> + (insert ";; -*- mode: lisp-data -*-\n") ;just a suggestion >> (eat--trace-log time 'create 'eat width height >> variables)))))) >>=20=20 > > TODO. > Done. [...] =2D-=20 Akib Azmain Turja, GPG key: 70018CE5819F17A3BBA666AFE74F0EFA922AE7F5 Fediverse: akib@hostux.social Codeberg: akib emailselfdefense.fsf.org | "Nothing can be secure without encryption." --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEyVTKmrtL6kNBe3FRVTX89U2IYWsFAmOFBu0ACgkQVTX89U2I YWtapxAAnePoKr/f2zcIfuHBtPSl4SOAkYww5r0OIgwcMXjuW/npUvWZf/uHYeMq jzPjlZ/s5yWV7hGYd/YglM4F+QJGuTtv4VKQVLqTCKqlk56PG3+rmaZgMoz17Zak mAeWqtGGQ/1w+9F0IwIy1UQEwZHnbjR9PKQRGxXHzOexC0Ny3yhd2P6jf5XTmKyJ QChZvFrJWW9B/jp2BjGD8ageerNzLyTMXUkOm35KMCPACYyT1SMi8iv+Kc+8A3CE DpMsPGBUFoqBkPWzEG/vv24rv2KSHPeYY1ApBkuTlwRtKbO9w51MAD4Fw1x5Y/i8 yJZOrcUnZdISCUIW2Uq4c2gfCmtKRr+NvTyHGJvubKGL6pag+lFPgeIwrqfvtYTk QoitLpuTp6wz7TGacA7GRmjwafVYFAy0iVBSkhHlcbHYnYTperMpAWrD4CPoHQ2R TuGzF9c2V0ggl4F9/xNngt8F4EJUTLurc/rSGtKEfSKkLzQOv5Dd7/p/TIxddxO8 aKBRPgASl0SFgQrbombHNNL92lMU16iWksY7E1F7rx/bAxyrDQck0qn/aOe0B8oa NxMKLtc6kBa+LA5/DYa76Ypq3BsLwSmXB5AK6fcGdXFhCH6sDs9VRdHNHA4Z4BjM D7zvkr8er7UTbjv6vU6rO57vPiIclEPwq2pzbZONPauQxHysHRQ= =GJ2P -----END PGP SIGNATURE----- --=-=-=--