all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Akib Azmain Turja <akib@disroot.org>
Cc: Emacs Developer List <emacs-devel@gnu.org>
Subject: Re: [NonGNU ELPA] 11 new packages!
Date: Mon, 21 Nov 2022 18:32:29 +0000	[thread overview]
Message-ID: <87wn7o9n0i.fsf@posteo.net> (raw)
In-Reply-To: <875yfdd5ad.fsf@disroot.org> (Akib Azmain Turja's message of "Thu, 17 Nov 2022 20:28:10 +0600")

[-- Attachment #1: Type: text/plain, Size: 581 bytes --]

Akib Azmain Turja <akib@disroot.org> writes:

> Philip Kaludercic <philipk@posteo.net> writes:
>
>>>> OK, then adding them to NonGNU ELPA seems like the safer bet.
>>>>
>>>> I'd like to add them, but I'll have to take the time to review them
>>>> first, which might take a bit.
>>>
>>> What do you want to review?  The patches, or the packages?
>>
>> The packages, unless you aren't interested in comments.
>
> Review if you wish, I welcome feedback.

I've managed to skim through workroom.el.  The code looks great, so I
just have a non-comprehensive list of comments and ideas:


[-- Attachment #2: Type: text/plain, Size: 6559 bytes --]

diff --git a/workroom.el b/workroom.el
index 7091645b85..8bb564e495 100644
--- a/workroom.el
+++ b/workroom.el
@@ -217,12 +217,13 @@ The value is a mode line terminal like `mode-line-format'."
     keymap)
   "Keymap containing all useful commands of Workroom.")
 
-(defvar workroom-mode-map (make-sparse-keymap)
+(defvar workroom-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map workroom-command-map-prefix
+		workroom-command-map)
+    map)
   "Keymap for Workroom mode.")
 
-(define-key workroom-mode-map workroom-command-map-prefix
-            workroom-command-map)
-
 (defun workroom-rebind-command-map-prefix ()
   "Rebind command prefix key sequence `workroom-command-map-prefix'."
   (substitute-key-definition
@@ -234,6 +235,7 @@ The value is a mode line terminal like `mode-line-format'."
 ;;;; Workroom and View Manipulation.
 
 (cl-defstruct (workroom--room
+	       (:predicate workroomp)
                (:constructor workroom--make-room)
                (:copier workroom--copy-room))
   "Structure for workroom."
@@ -253,6 +255,7 @@ The value is a mode line terminal like `mode-line-format'."
    :documentation "`completing-read' history of view names."))
 
 (cl-defstruct (workroom--view
+	       (:predicate workroom-view-p)
                (:constructor workroom--make-view)
                (:copier workroom--copy-view))
   "Structure for view of workroom."
@@ -268,7 +271,7 @@ The value is a mode line terminal like `mode-line-format'."
 (defvar workroom--dont-clear-new-view nil
   "Non-nil mean don't clear empty new views.")
 
-(defvar workroom--rooms nil
+(defvar workroom--rooms nil		;maybe some comments on the structure
   "List of currently live workrooms.")
 
 (defvar workroom-room-history nil
@@ -283,10 +286,6 @@ that.")
 
 (defvar workroom-mode)
 
-(defun workroomp (object)
-  "Return non-nil if OBJECT is a workroom object."
-  (workroom--room-p object))
-
 (defun workroom-name (room)
   "Return the name of workroom ROOM."
   (workroom--room-name room))
@@ -384,10 +383,6 @@ effect, it is not unaltered."
   "Completing read history of view of workroom ROOM."
   (workroom--room-view-history room))
 
-(defun workroom-view-p (object)
-  "Return non-nil if OBJECT is a view object."
-  (workroom--view-p object))
-
 (defun workroom-view-name (view)
   "Return the name of view VIEW."
   (workroom--view-name view))
@@ -435,10 +430,9 @@ A copy is returned, so it can be modified with side-effects."
   "Return the workroom named NAME.
 
 If no such workroom exists, return nil."
-  (catch 'found
-    (dolist (room workroom--rooms nil)
-      (when (string= name (workroom-name room))
-        (throw 'found room)))))
+  (cl-find name workroom--rooms
+	   :key #'workroom-name
+	   :test #'string=))
 
 (defun workroom-get-create (name)
   "Return the workroom named NAME.
@@ -500,7 +494,7 @@ If no such view exists, create a new one named NAME and return that."
     (unless view
       (setq view (workroom--make-view :name name))
       (setf (workroom--room-view-list room)
-            (nconc (workroom--room-view-list room) `(,view))))
+            (nconc (workroom--room-view-list room) (list view))))
     view))
 
 (defun workroom-generate-new-view-name (room name)
@@ -516,7 +510,7 @@ name."
       (let ((n 2))
         (while t
           (let ((str (format "%s<%i>" name n)))
-            (when (not (workroom-view-get room str))
+            (unless (workroom-view-get room str)
               (cl-return str))
             (cl-incf n)))))))
 
@@ -558,7 +552,7 @@ Return DEF when input is empty, where DEF is either a string or nil.
 
 REQUIRE-MATCH and PREDICATE is same as in `completing-read'."
   (completing-read
-   (concat prompt (when def (format " (default %s)" def)) ": ")
+   (concat prompt (and def (format " (default %s)" def)) ": ") ;Compat has `format-prompt'
    (mapcar #'workroom-name workroom--rooms) predicate require-match
    nil 'workroom-room-history def))
 
@@ -670,7 +664,7 @@ If WRITABLE, return a writable object."
 (defun workroom--load-window-config (state)
   "Load window configuration STATE."
   (if state
-      (cl-labels
+      (cl-labels			;perhaps this should be split up?
           ((sanitize (entry)
              (cond
               ;; Do nothing.
@@ -1254,7 +1248,7 @@ ACTION and ARGS are also described there."
   (setf (workroom-buffer-manager-data room)
         (cl-delete-if-not #'buffer-live-p
                           (workroom-buffer-manager-data room)))
-  (pcase action
+  (pcase action				;perhaps match on (cons action args)?
     (:initialize
      (cl-destructuring-bind () args
        (setf (workroom-buffer-manager-data room)
@@ -1507,9 +1501,14 @@ restrict."
 
 (defun workroom--encode-view-1 (view)
   "Encode view VIEW to a writable object."
-  `( :name ,(workroom-view-name view)
-     :window-config ,(workroom-view-window-configuration
-                      view 'writable)))
+  ;; I think it is preferable to define plists with keywords using
+  ;; `list', as all the members of the list can be evaluated during
+  ;; application.
+  (list :name
+	(workroom-view-name view)
+	:window-config
+	(workroom-view-window-configuration
+	 view 'writable)))
 
 (defun workroom--decode-view-1 (object)
   "Decode encoded view OBJECT to a view."
@@ -1589,7 +1588,7 @@ when ROOM was encoded."
 
 (defun workroom-decode-buffer-bookmark (object)
   "Decode OBJECT using `bookmark-jump'."
-  (let* ((buffer nil))
+  (let ((buffer nil))
     (bookmark-jump object (lambda (buf) (setq buffer buf)))
     buffer))
 
@@ -1664,7 +1663,7 @@ any previous bookmark with the same name."
                                      bookmark)))))
     (pcase (plist-get data :version)
       (1
-       (let* ((buffers (cl-delete-if
+       (let ((buffers (cl-delete-if
                         #'null
                         (workroom--decode-buffers
                          (plist-get data :buffers)))))
@@ -1787,6 +1786,7 @@ any previous bookmark with the same name."
   ;; Inject restoring code.
   (when workroom-mode
     (let ((time (format-time-string "%s%N")))
+      ;; I like to use `prin1-to-string' for things like these.
       (insert
        (format
         "
@@ -1951,6 +1951,7 @@ argument while setting as the buffer manager, PROJECT, the project."
 (defun workroom--project-name (project)
   "Return a name for project PROJECT."
   (let ((root (project-root project)))
+    ;; Isn't this `file-name-base' or `directory-file-name'?
     (if (string-match "/\\([^/]+\\)/?\\'" root)
         (match-string 1 root)
       root)))

  reply	other threads:[~2022-11-21 18:32 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14  7:42 [NonGNU ELPA] 11 new packages! Akib Azmain Turja
2022-11-15 17:42 ` Akib Azmain Turja
2022-11-15 19:53 ` Filipp Gunbin
2022-11-16 12:22   ` Akib Azmain Turja
2022-11-16 16:53     ` Eli Zaretskii
2022-11-16 17:43       ` Akib Azmain Turja
2022-11-16 19:47         ` Eli Zaretskii
2022-11-17 14:27           ` Akib Azmain Turja
2022-11-17 18:41             ` Stefan Monnier
2022-11-17 18:51             ` Yuan Fu
2022-11-24 23:38               ` Richard Stallman
2022-11-17 18:56             ` Eli Zaretskii
2022-11-15 19:57 ` Philip Kaludercic
2022-11-16 12:25   ` Akib Azmain Turja
2022-11-16 16:07     ` Philip Kaludercic
2022-11-16 17:45       ` Akib Azmain Turja
2022-11-16 18:19         ` Philip Kaludercic
2022-11-17 14:28           ` Akib Azmain Turja
2022-11-21 18:32             ` Philip Kaludercic [this message]
2022-11-22 15:20               ` Akib Azmain Turja
2022-11-22 17:07                 ` Philip Kaludercic
2022-11-22 17:42                   ` Akib Azmain Turja
2022-11-25  8:29                     ` Akib Azmain Turja
2022-11-25 16:32                       ` Philip Kaludercic
2022-11-25 17:14                         ` Akib Azmain Turja
2022-11-22 21:16                 ` Stefan Monnier
2022-11-25  7:14             ` Philip Kaludercic
2022-11-25  7:22               ` Philip Kaludercic
2022-11-25 12:45                 ` Akib Azmain Turja
2022-11-25 13:07               ` Akib Azmain Turja
2022-11-25 17:16                 ` Akib Azmain Turja
2022-11-25 17:31                 ` Philip Kaludercic
2022-11-26  5:53                   ` Akib Azmain Turja
2022-11-26 20:12                     ` Stefan Monnier
2022-11-25 19:07             ` Philip Kaludercic
2022-11-26  7:49               ` Akib Azmain Turja
2022-11-27  8:11                 ` Philip Kaludercic
2022-11-27 19:22                   ` Akib Azmain Turja
2022-11-27 19:55                   ` Akib Azmain Turja
2022-11-27 20:30                     ` Philip Kaludercic
2022-11-26 18:44               ` Akib Azmain Turja
2022-11-26 20:07             ` Philip Kaludercic
2022-11-26 20:17               ` Philip Kaludercic
2022-11-26 21:12                 ` Akib Azmain Turja
2022-11-27 11:45                   ` Philip Kaludercic
2022-11-27 17:04                     ` Akib Azmain Turja
2022-11-27 20:26                       ` Philip Kaludercic
2022-11-28 19:07                       ` Akib Azmain Turja
2022-11-28 19:42                         ` Philip Kaludercic
2022-11-28 20:32                           ` Akib Azmain Turja
2022-11-28 20:57                         ` Stefan Monnier
2022-11-27 18:40                   ` [NonGNU ELPA] 12 " Akib Azmain Turja
2022-11-27 20:36                     ` Philip Kaludercic
2022-11-27 21:11                       ` Akib Azmain Turja
2022-11-27  6:40               ` [NonGNU ELPA] 11 " Akib Azmain Turja
2022-11-19 12:05     ` Richard Stallman
2022-11-19 12:17       ` Philip Kaludercic

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=87wn7o9n0i.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=akib@disroot.org \
    --cc=emacs-devel@gnu.org \
    /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.