From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 70622@debbugs.gnu.org
Subject: bug#70622: [PATCH] New window parameter 'cursor-type'
Date: Sun, 28 Apr 2024 08:27:53 +0200 [thread overview]
Message-ID: <m1il02ypau.fsf@dazzs-mbp.kpn> (raw)
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
Tags: patch
This patch makes it possible to set the cursor type in a specific window,
without affecting other windows that may be showing the same buffer.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-New-window-parameter-cursor-type.patch --]
[-- Type: text/patch, Size: 3675 bytes --]
From 518a6708c6d94f152c9cb9ca7a8c73aeffa4a03a Mon Sep 17 00:00:00 2001
From: Eshel Yaron <me@eshelyaron.com>
Date: Sat, 27 Apr 2024 20:47:34 +0200
Subject: [PATCH] New window parameter 'cursor-type'
* src/xdisp.c (get_window_cursor_type): Consult new window
parameter 'cursor-type'.
* doc/lispref/windows.texi (Window Parameters): Document it.
* etc/NEWS: Announce it.
---
doc/lispref/windows.texi | 9 +++++++++
etc/NEWS | 6 ++++++
src/xdisp.c | 28 ++++++++++++++++++----------
3 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 104420235df..19154692056 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -6691,6 +6691,15 @@ Window Parameters
window and should be used, with due care, exclusively by those
applications. It might be replaced by an improved solution in future
versions of Emacs.
+
+@item cursor-type
+@vindex cursor-type@r{, a window parameter}
+If this parameter is set to a cons cell, its @sc{car} specifies the
+shape of the cursor in this window, using the same format as the
+buffer-local variable @code{cursor-type}. @xref{Cursor Parameters}.
+Use this window parameter instead of the @code{cursor-type} variable or
+frame parameter when a buffer is displayed in multiple windows and you
+want to change the cursor for one window without affecting the others.
@end table
diff --git a/etc/NEWS b/etc/NEWS
index 9c356e64bde..e08998e4b6f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -340,6 +340,12 @@ and 'window-state-get'. Then later another new variable
'window-state-put' to restore positions of window points
according to the context stored in a window parameter.
++++
+*** New window parameter 'cursor-type'.
+If this parameter is set to a cons cell, its 'car' specifies the shape
+of the window's cursor, using the same format as the buffer-local
+variable 'cursor-type'.
+
** Tab Bars and Tab Lines
---
diff --git a/src/xdisp.c b/src/xdisp.c
index 85802ec5083..ac2b2d186ff 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -33605,7 +33605,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
struct frame *f = XFRAME (w->frame);
struct buffer *b = XBUFFER (w->contents);
int cursor_type = DEFAULT_CURSOR;
- Lisp_Object alt_cursor;
+ Lisp_Object alt_cursor, win_cursor;
bool non_selected = false;
*active_cursor = true;
@@ -33644,18 +33644,26 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
non_selected = true;
}
- /* Never display a cursor in a window in which cursor-type is nil. */
- if (NILP (BVAR (b, cursor_type)))
- return NO_CURSOR;
-
- /* Get the normal cursor type for this window. */
- if (EQ (BVAR (b, cursor_type), Qt))
+ win_cursor = window_parameter (w, Qcursor_type);
+ if (CONSP (win_cursor))
{
- cursor_type = FRAME_DESIRED_CURSOR (f);
- *width = FRAME_CURSOR_WIDTH (f);
+ cursor_type = get_specified_cursor_type (XCAR (win_cursor), width);
}
else
- cursor_type = get_specified_cursor_type (BVAR (b, cursor_type), width);
+ {
+ /* Never display a cursor in a window in which cursor-type is nil. */
+ if (NILP (BVAR (b, cursor_type)))
+ return NO_CURSOR;
+
+ /* Get the normal cursor type for this window. */
+ if (EQ (BVAR (b, cursor_type), Qt))
+ {
+ cursor_type = FRAME_DESIRED_CURSOR (f);
+ *width = FRAME_CURSOR_WIDTH (f);
+ }
+ else
+ cursor_type = get_specified_cursor_type (BVAR (b, cursor_type), width);
+ }
/* Use cursor-in-non-selected-windows instead
for non-selected window or frame. */
--
2.44.0
next reply other threads:[~2024-04-28 6:27 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-28 6:27 Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-04-28 7:22 ` bug#70622: [PATCH] New window parameter 'cursor-type' Eli Zaretskii
2024-04-28 15:00 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-28 15:29 ` Eli Zaretskii
2024-04-28 19:05 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-29 6:31 ` Eli Zaretskii
2024-04-29 8:18 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-29 9:08 ` Eli Zaretskii
2024-04-29 9:48 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-29 11:10 ` Eli Zaretskii
2024-04-30 9:03 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-30 12:12 ` Eli Zaretskii
2024-05-09 7:44 ` Eli Zaretskii
2024-05-09 10:56 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-09 11:25 ` Eli Zaretskii
2024-05-09 14:19 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-10 8:58 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-10 16:20 ` Eli Zaretskii
2024-05-11 7:35 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-11 8:34 ` Eli Zaretskii
2024-05-12 8:29 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-12 9:39 ` Eli Zaretskii
2024-05-12 12:33 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-13 8:05 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-13 12:13 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-18 9:43 ` Eli Zaretskii
2024-05-18 13:45 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-10 16:19 ` Eli Zaretskii
2024-04-29 9:48 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=m1il02ypau.fsf@dazzs-mbp.kpn \
--to=bug-gnu-emacs@gnu.org \
--cc=70622@debbugs.gnu.org \
--cc=me@eshelyaron.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).