* How do I tell when the current buffer is the minibuffer? @ 2016-03-05 21:02 Alan Mackenzie 2016-03-05 21:39 ` raman 2016-03-05 22:04 ` Andreas Schwab 0 siblings, 2 replies; 12+ messages in thread From: Alan Mackenzie @ 2016-03-05 21:02 UTC (permalink / raw) To: emacs-devel Hello, Emacs. My problem is as stated in the Subject: line. Part of my program is being called from `signal_after_change' after activity in the minibuffer. However, in that program the buffer local variables for the main buffer (not the minibuffer) are still in scope. I need some way of distinguishing that we're in the minibuffer so as to avoid corrupting the buffer local variables of the selected buffer. I've tried "Fminibufferp (Qnil);", but this seems just to return nil, even when the current buffer IS the minibuffer. I've even tried reading the fine manual without finding anything useful. Would somebody please tell me what I'm missing. Thanks! -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-05 21:02 How do I tell when the current buffer is the minibuffer? Alan Mackenzie @ 2016-03-05 21:39 ` raman 2016-03-05 22:04 ` Andreas Schwab 1 sibling, 0 replies; 12+ messages in thread From: raman @ 2016-03-05 21:39 UTC (permalink / raw) To: Alan Mackenzie; +Cc: emacs-devel Alan Mackenzie <acm@muc.de> writes: minibuffer-window-active-p perhaps > Hello, Emacs. > > My problem is as stated in the Subject: line. > > Part of my program is being called from `signal_after_change' after > activity in the minibuffer. However, in that program the buffer local > variables for the main buffer (not the minibuffer) are still in scope. > > I need some way of distinguishing that we're in the minibuffer so as to > avoid corrupting the buffer local variables of the selected buffer. > > I've tried "Fminibufferp (Qnil);", but this seems just to return nil, > even when the current buffer IS the minibuffer. > > I've even tried reading the fine manual without finding anything useful. > > Would somebody please tell me what I'm missing. > > Thanks! -- ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-05 21:02 How do I tell when the current buffer is the minibuffer? Alan Mackenzie 2016-03-05 21:39 ` raman @ 2016-03-05 22:04 ` Andreas Schwab 2016-03-05 22:19 ` Alan Mackenzie 1 sibling, 1 reply; 12+ messages in thread From: Andreas Schwab @ 2016-03-05 22:04 UTC (permalink / raw) To: Alan Mackenzie; +Cc: emacs-devel Alan Mackenzie <acm@muc.de> writes: > Part of my program is being called from `signal_after_change' after > activity in the minibuffer. However, in that program the buffer local > variables for the main buffer (not the minibuffer) are still in scope. How can that happen? A minibuffer is a buffer on its own, with its own local variables. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-05 22:04 ` Andreas Schwab @ 2016-03-05 22:19 ` Alan Mackenzie 2016-03-05 22:40 ` Andreas Schwab 2016-03-06 20:15 ` Johan Bockgård 0 siblings, 2 replies; 12+ messages in thread From: Alan Mackenzie @ 2016-03-05 22:19 UTC (permalink / raw) To: Andreas Schwab; +Cc: emacs-devel Hello, Andreas. On Sat, Mar 05, 2016 at 11:04:57PM +0100, Andreas Schwab wrote: > Alan Mackenzie <acm@muc.de> writes: > > Part of my program is being called from `signal_after_change' after > > activity in the minibuffer. However, in that program the buffer local > > variables for the main buffer (not the minibuffer) are still in scope. > How can that happen? A minibuffer is a buffer on its own, with its own > local variables. What is happening is that the variable location (created in C) is being shared by all buffers until a buffer local value is "primed" in a buffer with a `setq' invocation. How does one correctly create a buffer local variable in C? What I have at the moment is: DEFSYM (Qcomment_depth_hwm, "comment-depth-hwm"); DEFVAR_LISP ("comment-depth-hwm", Vcomment_depth_hwm, doc: /* Buffer position below which the `comment-depth' property is valid. */); Vcomment_depth_hwm = make_number (1); Fmake_variable_buffer_local (Qcomment_depth_hwm); This is clearly inadequate, of itself, to create a buffer local variable. > Andreas. > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 > "And now for something completely different." -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-05 22:19 ` Alan Mackenzie @ 2016-03-05 22:40 ` Andreas Schwab 2016-03-05 22:51 ` Alan Mackenzie 2016-03-06 20:15 ` Johan Bockgård 1 sibling, 1 reply; 12+ messages in thread From: Andreas Schwab @ 2016-03-05 22:40 UTC (permalink / raw) To: Alan Mackenzie; +Cc: emacs-devel Alan Mackenzie <acm@muc.de> writes: > How does one correctly create a buffer local variable in C? What I have > at the moment is: > > DEFSYM (Qcomment_depth_hwm, "comment-depth-hwm"); > DEFVAR_LISP ("comment-depth-hwm", Vcomment_depth_hwm, > doc: /* Buffer position below which the `comment-depth' property is valid. */); > Vcomment_depth_hwm = make_number (1); > Fmake_variable_buffer_local (Qcomment_depth_hwm); > > This is clearly inadequate, of itself, to create a buffer local variable. In which way? Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-05 22:40 ` Andreas Schwab @ 2016-03-05 22:51 ` Alan Mackenzie 2016-03-05 23:03 ` Andreas Schwab 2016-03-08 5:00 ` Stefan Monnier 0 siblings, 2 replies; 12+ messages in thread From: Alan Mackenzie @ 2016-03-05 22:51 UTC (permalink / raw) To: Andreas Schwab; +Cc: emacs-devel Hello, Andreas. On Sat, Mar 05, 2016 at 11:40:15PM +0100, Andreas Schwab wrote: > Alan Mackenzie <acm@muc.de> writes: > > How does one correctly create a buffer local variable in C? What I have > > at the moment is: > > DEFSYM (Qcomment_depth_hwm, "comment-depth-hwm"); > > DEFVAR_LISP ("comment-depth-hwm", Vcomment_depth_hwm, > > doc: /* Buffer position below which the `comment-depth' property is valid. */); > > Vcomment_depth_hwm = make_number (1); > > Fmake_variable_buffer_local (Qcomment_depth_hwm); > > This is clearly inadequate, of itself, to create a buffer local variable. > In which way? Until a `setq' (or the like) is done on the variable for a particular buffer, C code reading/writing from Vcomment_depth_hwm reads and writes the same piece of RAM that all other buffers do. In the mean time, I've been looking around, and it might well be that the correct way to create a buffer local variable in C is to use the macro DEFVAR_PER_BUFFER in buffer.c. It's doesn't seem documented (outside of buffer.c), though. > Andreas. > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 > "And now for something completely different." -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-05 22:51 ` Alan Mackenzie @ 2016-03-05 23:03 ` Andreas Schwab 2016-03-05 23:20 ` Alan Mackenzie 2016-03-08 5:00 ` Stefan Monnier 1 sibling, 1 reply; 12+ messages in thread From: Andreas Schwab @ 2016-03-05 23:03 UTC (permalink / raw) To: Alan Mackenzie; +Cc: emacs-devel Alan Mackenzie <acm@muc.de> writes: > Hello, Andreas. > > On Sat, Mar 05, 2016 at 11:40:15PM +0100, Andreas Schwab wrote: >> Alan Mackenzie <acm@muc.de> writes: > >> > How does one correctly create a buffer local variable in C? What I have >> > at the moment is: > >> > DEFSYM (Qcomment_depth_hwm, "comment-depth-hwm"); >> > DEFVAR_LISP ("comment-depth-hwm", Vcomment_depth_hwm, >> > doc: /* Buffer position below which the `comment-depth' property is valid. */); >> > Vcomment_depth_hwm = make_number (1); >> > Fmake_variable_buffer_local (Qcomment_depth_hwm); > >> > This is clearly inadequate, of itself, to create a buffer local variable. > >> In which way? > > Until a `setq' (or the like) is done on the variable for a particular > buffer, C code reading/writing from Vcomment_depth_hwm reads and writes > the same piece of RAM that all other buffers do. That seems to work for deactivate-mark. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-05 23:03 ` Andreas Schwab @ 2016-03-05 23:20 ` Alan Mackenzie 2016-03-06 17:44 ` Eli Zaretskii 0 siblings, 1 reply; 12+ messages in thread From: Alan Mackenzie @ 2016-03-05 23:20 UTC (permalink / raw) To: Andreas Schwab; +Cc: emacs-devel Hello again, Andreas. On Sun, Mar 06, 2016 at 12:03:50AM +0100, Andreas Schwab wrote: > Alan Mackenzie <acm@muc.de> writes: > > On Sat, Mar 05, 2016 at 11:40:15PM +0100, Andreas Schwab wrote: > >> Alan Mackenzie <acm@muc.de> writes: > >> > How does one correctly create a buffer local variable in C? What I have > >> > at the moment is: > >> > DEFSYM (Qcomment_depth_hwm, "comment-depth-hwm"); > >> > DEFVAR_LISP ("comment-depth-hwm", Vcomment_depth_hwm, > >> > doc: /* Buffer position below which the `comment-depth' property is valid. */); > >> > Vcomment_depth_hwm = make_number (1); > >> > Fmake_variable_buffer_local (Qcomment_depth_hwm); > >> > This is clearly inadequate, of itself, to create a buffer local variable. > >> In which way? > > Until a `setq' (or the like) is done on the variable for a particular > > buffer, C code reading/writing from Vcomment_depth_hwm reads and writes > > the same piece of RAM that all other buffers do. > That seems to work for deactivate-mark. It's not working for comment-depth-hwm. Perhaps somebody who understands this will chip in, here. It could really do with being in the Elisp manual. > Andreas. > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 > "And now for something completely different." -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-05 23:20 ` Alan Mackenzie @ 2016-03-06 17:44 ` Eli Zaretskii 2016-03-06 21:44 ` Alan Mackenzie 0 siblings, 1 reply; 12+ messages in thread From: Eli Zaretskii @ 2016-03-06 17:44 UTC (permalink / raw) To: Alan Mackenzie; +Cc: schwab, emacs-devel > Date: Sat, 5 Mar 2016 23:20:43 +0000 > From: Alan Mackenzie <acm@muc.de> > Cc: emacs-devel@gnu.org > > On Sun, Mar 06, 2016 at 12:03:50AM +0100, Andreas Schwab wrote: > > Alan Mackenzie <acm@muc.de> writes: > > > > On Sat, Mar 05, 2016 at 11:40:15PM +0100, Andreas Schwab wrote: > > >> Alan Mackenzie <acm@muc.de> writes: > > > >> > How does one correctly create a buffer local variable in C? What I have > > >> > at the moment is: > > > >> > DEFSYM (Qcomment_depth_hwm, "comment-depth-hwm"); > > >> > DEFVAR_LISP ("comment-depth-hwm", Vcomment_depth_hwm, > > >> > doc: /* Buffer position below which the `comment-depth' property is valid. */); > > >> > Vcomment_depth_hwm = make_number (1); > > >> > Fmake_variable_buffer_local (Qcomment_depth_hwm); > > > >> > This is clearly inadequate, of itself, to create a buffer local variable. > > > >> In which way? > > > > Until a `setq' (or the like) is done on the variable for a particular > > > buffer, C code reading/writing from Vcomment_depth_hwm reads and writes > > > the same piece of RAM that all other buffers do. > > > That seems to work for deactivate-mark. > > It's not working for comment-depth-hwm. > > Perhaps somebody who understands this will chip in, here. It could > really do with being in the Elisp manual. Is there still a problem? If so, please describe the details, because I don't think I understand them well enough to try helping you. (Yes, I've read what you wrote, but your description was too general and didn't include any code you tried to use, so I'm not sure what exactly did you try and how.) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-06 17:44 ` Eli Zaretskii @ 2016-03-06 21:44 ` Alan Mackenzie 0 siblings, 0 replies; 12+ messages in thread From: Alan Mackenzie @ 2016-03-06 21:44 UTC (permalink / raw) To: Eli Zaretskii; +Cc: schwab, emacs-devel Hello, Eli. On Sun, Mar 06, 2016 at 07:44:25PM +0200, Eli Zaretskii wrote: > > Date: Sat, 5 Mar 2016 23:20:43 +0000 > > From: Alan Mackenzie <acm@muc.de> > > Cc: emacs-devel@gnu.org > > On Sun, Mar 06, 2016 at 12:03:50AM +0100, Andreas Schwab wrote: > > > Alan Mackenzie <acm@muc.de> writes: > > > > On Sat, Mar 05, 2016 at 11:40:15PM +0100, Andreas Schwab wrote: > > > >> Alan Mackenzie <acm@muc.de> writes: > > > >> > How does one correctly create a buffer local variable in C? What I have > > > >> > at the moment is: > > > >> > DEFSYM (Qcomment_depth_hwm, "comment-depth-hwm"); > > > >> > DEFVAR_LISP ("comment-depth-hwm", Vcomment_depth_hwm, > > > >> > doc: /* Buffer position below which the `comment-depth' property is valid. */); > > > >> > Vcomment_depth_hwm = make_number (1); > > > >> > Fmake_variable_buffer_local (Qcomment_depth_hwm); > > > >> > This is clearly inadequate, of itself, to create a buffer local variable. > > > >> In which way? > > > > Until a `setq' (or the like) is done on the variable for a particular > > > > buffer, C code reading/writing from Vcomment_depth_hwm reads and writes > > > > the same piece of RAM that all other buffers do. > > > That seems to work for deactivate-mark. > > It's not working for comment-depth-hwm. > > Perhaps somebody who understands this will chip in, here. It could > > really do with being in the Elisp manual. > Is there still a problem? No, I solved it by putting the variable into buffer.c, accessed via BVAR. I'm still not sure if this is the canonical way to create a buffer local variable accessed from C. > If so, please describe the details, because I don't think I understand > them well enough to try helping you. (Yes, I've read what you wrote, > but your description was too general and didn't include any code you > tried to use, so I'm not sure what exactly did you try and how.) The problem was assigning a value to Vcomment_depth_hwm in C didn't create a buffer local copy of `comment-depth-hwm'. Why should it? I think the time it took me to find the solution is a problem. A 2003 copy of the XEmacs internals manual was helpful. ;-) -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-05 22:51 ` Alan Mackenzie 2016-03-05 23:03 ` Andreas Schwab @ 2016-03-08 5:00 ` Stefan Monnier 1 sibling, 0 replies; 12+ messages in thread From: Stefan Monnier @ 2016-03-08 5:00 UTC (permalink / raw) To: emacs-devel > Until a `setq' (or the like) is done on the variable for a particular > buffer, C code reading/writing from Vcomment_depth_hwm reads and writes > the same piece of RAM that all other buffers do. If/when you write to the variable and intend it to be a buffer-local change, you need to use Fset or Fmake_local_variable rather than just using a C-level assignment. Stefan ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How do I tell when the current buffer is the minibuffer? 2016-03-05 22:19 ` Alan Mackenzie 2016-03-05 22:40 ` Andreas Schwab @ 2016-03-06 20:15 ` Johan Bockgård 1 sibling, 0 replies; 12+ messages in thread From: Johan Bockgård @ 2016-03-06 20:15 UTC (permalink / raw) To: Alan Mackenzie; +Cc: Andreas Schwab, emacs-devel Alan Mackenzie <acm@muc.de> writes: > How does one correctly create a buffer local variable in C? What I have > at the moment is: > > DEFSYM (Qcomment_depth_hwm, "comment-depth-hwm"); > DEFVAR_LISP ("comment-depth-hwm", Vcomment_depth_hwm, > doc: /* Buffer position below which the `comment-depth' property is valid. */); > Vcomment_depth_hwm = make_number (1); > Fmake_variable_buffer_local (Qcomment_depth_hwm); > > This is clearly inadequate, of itself, to create a buffer local variable. Yes: (make-variable-buffer-local VARIABLE) Make VARIABLE become buffer-local whenever it is set. (make-local-variable VARIABLE) Make VARIABLE have a separate value in the current buffer. (Or DEFVAR_PER_BUFFER, as you said.) ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2016-03-08 5:00 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-03-05 21:02 How do I tell when the current buffer is the minibuffer? Alan Mackenzie 2016-03-05 21:39 ` raman 2016-03-05 22:04 ` Andreas Schwab 2016-03-05 22:19 ` Alan Mackenzie 2016-03-05 22:40 ` Andreas Schwab 2016-03-05 22:51 ` Alan Mackenzie 2016-03-05 23:03 ` Andreas Schwab 2016-03-05 23:20 ` Alan Mackenzie 2016-03-06 17:44 ` Eli Zaretskii 2016-03-06 21:44 ` Alan Mackenzie 2016-03-08 5:00 ` Stefan Monnier 2016-03-06 20:15 ` Johan Bockgård
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.