From: Eli Zaretskii <eliz@gnu.org>
To: Visuwesh <visuweshm@gmail.com>, adam@alphapapa.net
Cc: 74701@debbugs.gnu.org
Subject: bug#74701: 31.0.50; vtable: cannot drag to resize columns when :use-header-line is nil
Date: Sat, 21 Dec 2024 11:10:28 +0200 [thread overview]
Message-ID: <86jzbt8kqj.fsf@gnu.org> (raw)
In-Reply-To: <87jzcew69e.fsf@gmail.com> (message from Visuwesh on Thu, 05 Dec 2024 20:01:41 +0530)
Adam, any comments?
> Cc: Adam Porter <adam@alphapapa.net>
> From: Visuwesh <visuweshm@gmail.com>
> Date: Thu, 05 Dec 2024 20:01:41 +0530
>
> When creating a vtable with :use-header-line nil (see below), dragging
> the column or the divider to resize the column is impossible because
>
> 1. the function vtable--insert-header-line does not create the keymap
> so that non-header-line mouse bindings actually resize the column
> 2. after inserting the header-line, vtable-insert completely
> overwrites the keymap text-property which wipes out the keymap
> setup by vtable--insert-header-line
>
> To reproduce,
>
> 1. emacs -Q
> 2. Evaluate the following sexp
>
> (with-current-buffer (get-buffer-create "asd")
> (erase-buffer)
> (require 'vtable)
> (make-vtable
> :use-header-line nil
> :columns '("One" "Two")
> :objects '((1 2) (3 4) (5 6)))
> (pop-to-buffer (current-buffer)))
> 3. Try to resize the column "Two" ("T" is shown here) by clicking on
> "T" and dragging the pointer.
> 4. Witness no column resize.
> 5. Now, change :use-header-line to t and try to resize again.
> 6. Witness column resize.
>
> The patch below fixes the issue on my end
>
>
> diff --git a/lisp/emacs-lisp/vtable.el b/lisp/emacs-lisp/vtable.el
> index c4f14d7b4b2..6f04eca3da8 100644
> --- a/lisp/emacs-lisp/vtable.el
> +++ b/lisp/emacs-lisp/vtable.el
> @@ -544,7 +544,7 @@ vtable-insert
> ;; them).
> (vtable--insert-header-line table widths spacer)
> (add-text-properties start (point)
> - (list 'keymap vtable-header-line-map
> + (list ;;'keymap vtable-header-line-map
> 'rear-nonsticky t
> 'vtable table))
> (setq start (point))))
> @@ -706,24 +706,34 @@ vtable--indicator
>
> (defun vtable--insert-header-line (table widths spacer)
> ;; Insert the header directly into the buffer.
> - (let ((start (point))
> - (divider (vtable-divider table))
> - (cmap (define-keymap
> - "<header-line> <drag-mouse-1>" #'vtable--drag-resize-column
> - "<header-line> <down-mouse-1>" #'ignore))
> - (dmap (define-keymap
> - "<header-line> <drag-mouse-1>"
> - (lambda (e)
> - (interactive "e")
> - (vtable--drag-resize-column e t))
> - "<header-line> <down-mouse-1>" #'ignore)))
> + (let* ((start (point))
> + (divider (vtable-divider table))
> + (rev-resize-fun (lambda (e)
> + (interactive "e")
> + (vtable--drag-resize-column e t)))
> + (cmap (define-keymap
> + :parent vtable-header-line-map
> + "<header-line> <drag-mouse-1>" #'vtable--drag-resize-column
> + "<header-line> <down-mouse-1>" #'ignore
> + "<drag-mouse-1>" #'vtable--drag-resize-column
> + "<down-mouse-1>" #'ignore))
> + (dmap (define-keymap
> + :parent vtable-header-line-map
> + "<header-line> <drag-mouse-1>" rev-resize-fun
> + "<header-line> <down-mouse-1>" #'ignore
> + "<drag-mouse-1>" rev-resize-fun
> + "<down-mouse-1>" #'ignore)))
> (seq-do-indexed
> (lambda (column index)
> (let* ((name (propertize
> (vtable-column-name column)
> 'face (list 'header-line (vtable-face table))
> 'mouse-face 'header-line-highlight
> - 'keymap cmap))
> + ;; Reverse resizing is more intuitive for the first
> + ;; column.
> + 'keymap (if (= index 0)
> + dmap
> + cmap)))
> (start (point))
> (indicator (vtable--indicator table index))
> (indicator-width (string-pixel-width indicator))
>
>
> I also took the liberty to make one other change:
>
> I use DMAP instead of CMAP for the first column. Without this
> change, dragging the first column does nothing. With this change,
> dragging the first column to the left will increase its size. I
> think this behaviour is more intuitive than doing nothing.
>
> In GNU Emacs 31.0.50 (build 25, x86_64-pc-linux-gnu, X toolkit, cairo
> version 1.18.2, Xaw scroll bars) of 2024-11-10 built on astatine
> Repository revision: 1704fa4fb4164a15c7e258b922dbba190811d92d
> Repository branch: master
> Windowing system distributor 'The X.Org Foundation', version 11.0.12101014
> System Description: Debian GNU/Linux trixie/sid
>
> Configured using:
> 'configure --with-sound=alsa --with-x-toolkit=lucid --without-xaw3d
> --without-gconf --without-libsystemd --with-cairo CFLAGS=-g3'
> Configured features:
> ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
> LCMS2 LIBOTF LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
> SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM
> XINPUT2 XPM LUCID ZLIB
> Important settings:
> value of $LC_MONETARY: ta_IN.UTF-8
> value of $LC_NUMERIC: ta_IN.UTF-8
> value of $LANG: en_GB.UTF-8
> locale-coding-system: utf-8-unix
prev parent reply other threads:[~2024-12-21 9:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-05 14:31 bug#74701: 31.0.50; vtable: cannot drag to resize columns when :use-header-line is nil Visuwesh
2024-12-21 9:10 ` Eli Zaretskii [this message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86jzbt8kqj.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=74701@debbugs.gnu.org \
--cc=adam@alphapapa.net \
--cc=visuweshm@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).