[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cursor-in-non-selected-windows as buffer-local
From: |
md5i |
Subject: |
Re: cursor-in-non-selected-windows as buffer-local |
Date: |
Wed, 31 Oct 2001 15:04:30 -0500 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1 (i686-pc-linux-gnu) |
address@hidden writes:
> I looked all over the place and couldn't find an easy way to get at
> buffer-local-variables in the context of another buffer. So I wrote a
> function to do just that. When writing it, it occured to me that it
> might be nice to have on the lisp level as well, so I did that as
> well. I called it `buffer-local-value', but maybe it should be
> renamed `value-in-buffer' or some such. This may not be desirable,
> but if that is the case, tell me so, and I will do it another way.
>
> If you accept the new lisp-level function, I will write documentation
> for it for the Emacs Lisp manual.
Found a bug in my patch. This is the real patch:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/src/ChangeLog,v
retrieving revision 1.2136
diff -u -r1.2136 ChangeLog
--- ChangeLog 2001/10/31 17:27:50 1.2136
+++ ChangeLog 2001/10/31 20:00:56
@@ -1,3 +1,10 @@
+2001-10-31 Michael Welsh Duggan <address@hidden>
+
+ * buffer.c (Fbuffer_local_value): New function.
+
+ * xterm.c, w32term.c (x_display_and_set_cursor): Use buffer-local
+ value of `cursor-in-non-selected-windows'.
+
2001-10-31 Eli Zaretskii <address@hidden>
* s/hpux11.h: New file.
Index: buffer.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/buffer.c,v
retrieving revision 1.367
diff -u -r1.367 buffer.c
--- buffer.c 2001/10/31 15:04:58 1.367
+++ buffer.c 2001/10/31 20:01:01
@@ -808,6 +808,58 @@
return base_buffer;
}
+DEFUN ("buffer-local-value", Fbuffer_local_value,
+ Sbuffer_local_value, 2, 2, 0,
+ doc: /* Returns the buffer-local value of SYMBOL in BUFFER.
+If SYMBOL does not have a buffer-local binding in BUFFER, it will
+return the default binding of SYMBOL. */)
+ (symbol, buffer)
+ register Lisp_Object symbol;
+ register Lisp_Object buffer;
+{
+ register struct buffer *buf;
+ register Lisp_Object result;
+
+ CHECK_SYMBOL (symbol, 0);
+ CHECK_BUFFER (buffer, 0);
+ buf = XBUFFER (buffer);
+
+ /* Look in local_var_list */
+ result = Fassoc (symbol, buf->local_var_alist);
+ if (NILP (result))
+ {
+ int offset, idx;
+ int found = 0;
+
+ /* Look in special slots */
+ for (offset = PER_BUFFER_VAR_OFFSET (name);
+ offset < sizeof (struct buffer);
+ /* sizeof EMACS_INT == sizeof Lisp_Object */
+ offset += (sizeof (EMACS_INT)))
+ {
+ idx = PER_BUFFER_IDX (offset);
+ if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx))
+ && SYMBOLP (PER_BUFFER_SYMBOL (offset)) &&
+ EQ (PER_BUFFER_SYMBOL (offset), symbol))
+ {
+ result = PER_BUFFER_VALUE (buf, offset);
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found)
+ result = Fdefault_value (symbol);
+ }
+ else
+ result = XCDR (result);
+
+ if (EQ (result, Qunbound))
+ return Fsignal (Qvoid_variable, Fcons (symbol, Qnil));
+
+ return result;
+}
+
DEFUN ("buffer-local-variables", Fbuffer_local_variables,
Sbuffer_local_variables, 0, 1, 0,
doc: /* Return an alist of variables that are buffer-local in BUFFER.
@@ -5571,6 +5623,7 @@
/*defsubr (&Sbuffer_number);*/
defsubr (&Sbuffer_file_name);
defsubr (&Sbuffer_base_buffer);
+ defsubr (&Sbuffer_local_value);
defsubr (&Sbuffer_local_variables);
defsubr (&Sbuffer_modified_p);
defsubr (&Sset_buffer_modified_p);
Index: w32term.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32term.c,v
retrieving revision 1.120
diff -u -r1.120 w32term.c
--- w32term.c 2001/10/27 22:21:24 1.120
+++ w32term.c 2001/10/31 20:01:12
@@ -9492,6 +9492,7 @@
struct glyph_matrix *current_glyphs;
struct glyph_row *glyph_row;
struct glyph *glyph;
+ int cursor_non_selected;
int active_cursor = 1;
/* This is pointless on invisible frames, and dangerous on garbaged
@@ -9528,6 +9529,9 @@
the cursor type given by the frame parameter. If explicitly
marked off, draw no cursor. In all other cases, we want a hollow
box cursor. */
+ cursor_non_selected =
+ !NILP (Fbuffer_local_value (intern ("cursor-in-non-selected-windows"),
+ w->buffer));
new_cursor_width = -1;
if (cursor_in_echo_area
&& FRAME_HAS_MINIBUF_P (f)
@@ -9546,11 +9550,10 @@
if (f != FRAME_W32_DISPLAY_INFO (f)->w32_highlight_frame
|| w != XWINDOW (f->selected_window))
{
- extern int cursor_in_non_selected_windows;
active_cursor = 0;
if (MINI_WINDOW_P (w)
- || !cursor_in_non_selected_windows
+ || !cursor_non_selected
|| NILP (XBUFFER (w->buffer)->cursor_type))
new_cursor_type = NO_CURSOR;
else
Index: xterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xterm.c,v
retrieving revision 1.677
diff -u -r1.677 xterm.c
--- xterm.c 2001/10/30 17:27:35 1.677
+++ xterm.c 2001/10/31 20:01:24
@@ -11459,6 +11459,7 @@
struct glyph_matrix *current_glyphs;
struct glyph_row *glyph_row;
struct glyph *glyph;
+ int cursor_non_selected;
/* This is pointless on invisible frames, and dangerous on garbaged
windows and frames; in the latter case, the frame or window may
@@ -11494,6 +11495,9 @@
the cursor type given by the frame parameter. If explicitly
marked off, draw no cursor. In all other cases, we want a hollow
box cursor. */
+ cursor_non_selected =
+ !NILP (Fbuffer_local_value (intern ("cursor-in-non-selected-windows"),
+ w->buffer));
new_cursor_width = -1;
if (cursor_in_echo_area
&& FRAME_HAS_MINIBUF_P (f)
@@ -11501,7 +11505,7 @@
{
if (w == XWINDOW (echo_area_window))
new_cursor_type = FRAME_DESIRED_CURSOR (f);
- else if (cursor_in_non_selected_windows)
+ else if (cursor_non_selected)
new_cursor_type = HOLLOW_BOX_CURSOR;
else
new_cursor_type = NO_CURSOR;
@@ -11511,10 +11515,8 @@
if (f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame
|| w != XWINDOW (f->selected_window))
{
- extern int cursor_in_non_selected_windows;
-
if (MINI_WINDOW_P (w)
- || !cursor_in_non_selected_windows
+ || !cursor_non_selected
|| NILP (XBUFFER (w->buffer)->cursor_type))
new_cursor_type = NO_CURSOR;
else
--
Michael Welsh Duggan
(address@hidden)