all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Lars Ingebrigtsen <larsi@gnus.org>, Boruch Baum <boruch_baum@gmx.com>
Cc: 32106@debbugs.gnu.org
Subject: bug#32106: 25.2: tabulated-list-resize-current-column [PATCH INCLUDED]
Date: Sun, 23 Jun 2019 19:56:23 -0700 (PDT)	[thread overview]
Message-ID: <19b9c926-3ec6-4130-a7d8-86fb82ac7061@default> (raw)
In-Reply-To: <m3zhm7yk98.fsf@gnus.org>

> The code looks good to me -- Eli points out that it would be great if
> you could mode the column sized with a mouse, too, but I think that's
> kinda an orthogonal issue.  If somebody were to add a mouse-drag thing
> for tabulated mode (and somebody should), then it looks like your
> function would perhaps work well as the underlying function for that
> command.
> 
> So unless anybody objects, I'd like to include this command in
> tabulated-list.el (and add documentation, of course).

Yes, this is welcome.  There are a few (relatively minor)
problems with it, which are easily corrected.  The code
below is a bit better, I think.

. The doc string was wrong wrt `tabulated-list-format'
  being a "defcustom" (an option) - it's not.  And that
  var is always buffer-local (as are most things about
  `tabulated-list-mode').  So there's no reason for
  this command's doc to say its change is buffer-local.

. There's a mix of meanings of "column" in the code and
  comments, starting with the main doc-string line:

    "Change width of the current column by N columns."

  It's clearer to use "column" only for either an Emacs
  character/buffer column or a `tabulated-list-mode'
  table column.  In the code below I chose the latter,
  never calling the former a "column".

. It's handier for users for the numeric arg to always
  be provided by the numeric prefix arg (default: 1).
  No prompting, and the command can then be repeated by
  just holding down a key.

. With that change, by default the command widens the
  current column width, and its name can reflect that.
  Increasing by a negative number decreases, as usual.
  A separate command to narrow the column (decrease
  its width) should also be provided, for easy key
  binding.  A user can bind both widen and narrow
  commands to repeatable keys.

. No need to remember the start column.  REMEMBER-POS
  arg to `tabulated-list-print' takes care of that.

(defun tabulated-list-widen-current-column (&optional n)
  "Widen the current tabulated-list column by prefix-arg chars."
  (interactive "p")
  (let ((start        (current-column))
        (nb-cols      (length tabulated-list-format))
        (col-nb       0)
        (total-width  0)
        (found        nil)
        col-width)
    (while (and (not found)  (< col-nb nb-cols))
      (if (> start
             (setq total-width
                   (+ total-width
                      (setq col-width
                            (cadr (aref tabulated-list-format
                                        col-nb))))))
          (setq col-nb  (1+ col-nb))
        (setq found  t)
        (setf (cadr (aref tabulated-list-format col-nb))
              (max 1 (+ col-width n)))
        (tabulated-list-print t)
        (tabulated-list-init-header)))))

(defun tabulated-list-narrow-current-column (&optional n)
  "Narrow the current tabulated list column by N chars.
See `tabulated-list-increase-current-column'."
  (interactive "p")
  (tabulated-list-increase-current-column (- n)))





  reply	other threads:[~2019-06-24  2:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-09 15:56 bug#32106: 25.2: tabulated-list-resize-current-column [PATCH INCLUDED] Boruch Baum
2018-07-09 17:22 ` Eli Zaretskii
2018-07-09 18:42   ` Boruch Baum
2019-06-23 23:06 ` Lars Ingebrigtsen
2019-06-24  2:56   ` Drew Adams [this message]
2019-06-24  5:29     ` Boruch Baum
2019-06-24 13:56       ` Drew Adams
2019-06-24 14:37     ` Lars Ingebrigtsen
2019-06-24 15:07       ` Boruch Baum
2019-06-24 16:03         ` Lars Ingebrigtsen
2019-06-25 19:35           ` Juri Linkov
2019-06-25 20:32             ` Lars Ingebrigtsen
2019-06-24 15:51       ` Drew Adams

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=19b9c926-3ec6-4130-a7d8-86fb82ac7061@default \
    --to=drew.adams@oracle.com \
    --cc=32106@debbugs.gnu.org \
    --cc=boruch_baum@gmx.com \
    --cc=larsi@gnus.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.