all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Daniel Semyonov <cmstr@dsemy.com>
Cc: emacs-devel@gnu.org
Subject: Re: Copyright assignment and questions about package submission
Date: Sat, 26 Dec 2020 17:13:51 -0500	[thread overview]
Message-ID: <jwvv9cokyox.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwv8s9kme1y.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 26 Dec 2020 17:01:39 -0500")

>>> Please fill the form below and send it to the FSF as instructed so they
>>> can send you the relevant paperwork to sign.
>> Thanks, I've sent the form.
>
> BTW, I just looked at your package.
>
> The code looks clean, but when I tried to enable it in my main Emacs
> session it got stuck in `swsw-update`, apparently more specifically
> inside `swsw--get-possible-ids` (see sample backtrace below obtained
> with `debug-on-quit`).
>
> It looks like your algorithm has a bad asymptotic complexity (my session
> has currently 88 frames, most of them with a single window in it).

Actually, it looks like a simple error where you used division instead
of logarithm, thus constructing a `sws-ids` that's exponentially longer
than the one you need.  The patch below makes it usable for me.

[ I'd still argue that you shouldn't bother to construct the whole
  `sws-ids` list but instead keep a counter which lets you build the
  "next" id on the fly.  But that's up to you.  ]


        Stefan


diff --git a/swsw.el b/swsw.el
index 7f26b63..e4bb743 100644
--- a/swsw.el
+++ b/swsw.el
@@ -66,12 +66,10 @@
 
 (defcustom swsw-id-chars '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
   "Base set of characters from which window IDs are constructed."
-  :group 'swsw
   :type '(repeat character))
 
 (defcustom swsw-minibuffer-id ?m
   "ID reserved for the minibuffer."
-  :group 'swsw
   :type '(character))
 
 (defcustom swsw-scope t
@@ -81,7 +79,6 @@ t means consider all windows on all existing frames.
   iconified frames.
 ‘visible’ means consider all windows on all visible frames.
 ‘current’ means consider only the currently selected frame."
-  :group 'swsw
   :type '(radio (const :tag "All windows on all frames" t)
                 (const
                  :tag "All windows on all visible and iconified frames." 0)
@@ -109,7 +106,6 @@ sole argument (turning it on)."
 This function is called with t as the sole argument when enabling
 ‘swsw-mode’, and with nil as the sole argument when disabling it.
 If set to ‘lighter’, use the mode line lighter of ‘swsw-mode’."
-  :group 'swsw
   :type '(radio (const :tag "Mode line lighter" lighter)
                 (function :tag "Display function"))
   :set #'swsw--set-display-function)
@@ -117,7 +113,6 @@ If set to ‘lighter’, use the mode line lighter of ‘swsw-mode’."
 (defcustom swsw-id-format " <%s>"
   "Format string for the window ID.
 %s is replaced with a representation of the window's ID."
-  :group 'swsw
   :type '(string))
 
 ;;;; Simple window switching minor mode:
@@ -147,12 +142,8 @@ If set to ‘lighter’, use the mode line lighter of ‘swsw-mode’."
 (defun swsw--get-id-length ()
   "Return the current length of a window ID."
   (let* ((windows (length (window-list-1 nil nil (swsw--get-scope))))
-         (chars (length swsw-id-chars))
-         (div (/ windows chars)))
-    ;; Check the remainder to avoid returning a longer length than necessary.
-    (if (= 0 (mod windows chars))
-        div
-      (1+ div))))
+         (chars (length swsw-id-chars)))
+    (ceiling (log windows chars))))
 
 (defun swsw-update-window (window)
   "Update information for WINDOW."




  reply	other threads:[~2020-12-26 22:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-24 13:05 Copyright assignment and questions about package submission Daniel Semyonov
2020-12-24 14:28 ` Stefan Monnier
2020-12-24 15:58   ` Daniel Semyonov
2020-12-26 22:01     ` Stefan Monnier
2020-12-26 22:13       ` Stefan Monnier [this message]
2020-12-27  9:30         ` Daniel Semyonov

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=jwvv9cokyox.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=cmstr@dsemy.com \
    --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.