🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.help
Article #188742

Can I do (minibuffer-prompt-width)?

#188742
From: Eric Eide
Date: Mon, 24 Jun 1991 21:30
51 lines
3088 bytes
In short, my question is: "Is it possible to determine the length of the prompt
in the minibuffer?"

In not-so-short, I'm writing a package of X mouse functions.  One of the
functions is "x-mouse-set-point," which is intended to select the window that
was just clicked and move point to the clicked position:

(defun x-mouse-set-point ()
  "Select the window under the X mouse and move point to the mouse position."
  ;; NOTE that at this point, x-mouse-down-window is the "clicked" window and
  ;; x-mouse-down-window-position is the clicked (X Y) coordinates, measured
  ;; from the top left corner of the x-mouse-down-window.
  (select-window x-mouse-down-window)
  (move-to-window-line (car (cdr x-mouse-down-window-position)))
  (move-to-column (if (zerop (window-hscroll))
		      (+ (car x-mouse-down-window-position) (current-column))
		    (+ (car x-mouse-down-window-position) (window-hscroll) -1))
		  ))

This function works great EXCEPT when the user clicks in the minibuffer.  In
that case, point is moved to the wrong column.  In the minibuffer, column zero
is at the right edge of the minibuffer prompt, NOT at the left edge of the
minibuffer's window.

To fix this problem, I need to change the call to "move-to-column" to something
like this:

  (move-to-column (- (if (zerop (window-hscroll))
			 (+ (car ...) (current-column))
		       (+ (car ...) (window-hscroll) -1))
+		     ;; Adjust for the minibuffer.
+		     (if (eq x-mouse-down-window (minibuffer-window))
+			 (minibuffer-prompt-width)
+		       0)))

But unfortunately for me, the function "minibuffer-prompt-width" doesn't exist!
I've looked through the GNU Emacs sources (18.55) and discovered that the
prompt width is available to C code, but I haven't found any way to access the
prompt width from Lisp code.  Is there a way?  Or failing that, is there a
workaround that I can use in my mouse package?

Thanks in advance for any pointers.

As an aside, it appears that the built-in function "coordinates-in-window-p"
cannot be used to check if a coordinate is in the minibuffer window.  When
given the minibuffer window, "coordinates-in-window-p" always returns nil.
Was "coordinates-in-window-p" intended to do this?  Why?

-------------------------------------------------------------------------------
Eric Eide         |           University of Utah Department of Computer Science
eeide@cs.utah.edu |  Buddhist to hot dog vendor: "Make me one with everything."
Technical Details
Message-ID: <1991Jun24.153008.6165@hellgate.utah.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!spool.mu.edu!caen!hellgate.utah.edu!asylum.utah.edu!eeide

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 103b8b,d654e3c34d3f7f04,start
X-Google-Attributes: gid103b8b,public
X-Google-ArrivalTime: 1991-06-24 22:02:24 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!spool.mu.edu!caen!hellgate.utah.edu!asylum.utah.edu!eeide
From: eeide%asylum.utah.edu@cs.utah.edu (Eric Eide)
Newsgroups: gnu.emacs.help
Subject: Can I do (minibuffer-prompt-width)?
Keywords: minibuffer prompt X mouse
Message-ID: <1991Jun24.153008.6165@hellgate.utah.edu>
Date: 24 Jun 91 21:30:08 GMT
Distribution: gnu
Organization: University of Utah CS Dept
Lines: 51