From: "Drew Adams" <drew.adams@oracle.com>
Cc: Miguel Frasson <frasson@altair.math.leidenuniv.nl>,
Emacs-Devel <emacs-devel@gnu.org>
Subject: RE: pop-up tool-bar
Date: Fri, 8 Oct 2004 12:03:37 -0700 [thread overview]
Message-ID: <FDELKNEBLPKKDCEBEJCBGEDLCIAA.drew.adams@oracle.com> (raw)
In-Reply-To: <m1pt3tp0zc.fsf-monnier+emacs@gnu.org>
What else have I tried? Well, I tried the code you offered, but it didn't
work for me, as I mentioned previously. You never replied to my report of
those pbs and my request for info on what I might be doing wrong (copied
below). Did you actually _run_ your code successfully?
If you have another suggestion, let's try it. But please _try_ this code
too, before dismissing it out of hand. Please pound on it, so we can see
just how brittle it is.
I'm curious: just what part of the quoted mouse-click fix do you find to be
a "really super ugly nasty brittle dark hack"? What makes it so? Are you
speaking in terms of the code being brittle or the user experience (e.g.
being nonintuitive), or both?
You raise (I guess) two issues:
- bad code
- bad user interface
I'm open to improvement on both accounts. But let's be specific about what
is wrong. In terms of the code, please point out just what is brittle/bad
style/poor performance/whatever or suggest improvements. In terms of the UI,
please _try_ the code, and then report on what you find to be a pb. So far,
you seem to be reacting to a description of the behavior, and, as I said,
it's easier to experience the behavior than to describe it.
Abstractly name-calling the code or the UI doesn't help, I think. Please be
specific. I'm sure that you can come up with good, concrete improvements,
just as you did with the Info quotes highlighting. You already did offer a
concrete suggestion about `make-variable-frame-local', which I used.
I think we should offer users a pop-up tool-bar feature; that's all. I don't
push for my implementation of that feature; the best implementation should
be used. Frankly, I'd rather that someone else code this feature.
Thanks,
Drew
-----Original Message-----From: Stefan
> The fix was to scroll the buffer (window) `tool-bar-lines' to compensate
for
> the window movement. This scrolling happens for mouse events only, since
> other events do not cause the problem (and you don't want to scroll the
> buffer each time you click a tool-bar button).
This kind of really super ugly nasty brittle dark hack should be kept for
extreme circumstances where there's really no other possible option.
What else have you tried?
Stefan
-----Original Message-----From: Drew Adams
Good input. I wasn't even aware of `make-variable-frame-local', though I see
now that it's at least as old as Emacs 20.
I see you put "valid" in quotes, but I'm still not sure I know what you
mean. If the next event is a (valid) mouse-down, that's seems to be OK. The
mouse-down occurs at the right position in the buffer (as evidenced by the
highlighted region and cursor position), so I don't think that's the pb.
What happens, I think, is that when the tool-bar disappears, without your
having moved the mouse relative to the display, the mouse nevertheless has
moved relative to the displayed buffer -- so a region has been selected.
Now that I think of it, that could provide a solution, if we could be sure
to know the tool-bar height at all times in terms of # of buffer lines. We
could scroll the buffer down that number of lines, to compensate for the
buffer lines moving up relative to the display because the tool-bar
disappears. Maybe I'll give that a try. (Looking at tool-bar margins and
button-relief margins might be kind of a pain, though, and perhaps the
tool-bar height is not always an integral number of buffer lines, and maybe
we'll have to worry about different-size fonts - ugh.)
Can you elaborate on your "Note" - Is it meant to apply to my original code
or to your code (or both)? With my code, if I click "Buttons" and then
delete the frame instead of clicking a button, it seems to behave as I would
expect, at least on Windows: the frame is gone, that's all.
Maybe I'm doing something wrong, but your code doesn't work for me:
- The tool-bar doesn't disappear afterward, no matter how I end
(click a button or do something else.
- "Buttons" doesn't come back to the menu-bar, and I can't get it
back again, even by turning tool-bar-mode on, then off.
- I get this error when I click "Buttons":
show-tool-bar-for-one-command: Wrong number of arguments:
(lambda (hook function append local)...
No doubt the first two symptoms are due to the last pb.
Don't you need an unwind-protect to be sure to turn the mode back off, in
case, for instance, the user does C-g -- or will the post-command-hook
always take care of that?
- Drew
---------------From: Stefan Monnier
It looks like the problem is that the event you get from read-event is not
"valid" any more after you remove the toolbar (becaue the position is
changed).
Using read-event is generally a source a trouble. But the alternatives
aren't great either. Maybe you can try something like the appended code.
Note: you should pay attention to the case where the frame has been deleted
by the next command.
Also, you declare your minor mode to be ":global t" but it is frame-local,
so you should add (make-variable-frame-local 'tool-bar-here-mode) somewhere
at the toplevel.
Stefan
(defun add-hook-once (hook function append local)
"Same as `add-hook', but FUN is only run once.
Also contrary to `add-hook', this is not idempotent."
(let ((code (list 'lambda)))
(setcdr code `(() (,function) (remove-hook ',hook ',code ',local)))
(add-hook hook code append local)))
...
(defun show-tool-bar-for-one-command ()
"Pop up the tool bar so you can click a button.
The tool bar stays visible until one command is executed
\(whether or not it was initiated by clicking a button)."
(interactive)
(tool-bar-here-mode 1)
(add-hook-once 'post-command-hook
`(lambda ()
;; We're just now done with
show-tool-bar-for-one-command.
(add-hook-once 'post-command-hook
(lambda ()
;; We're done with the next command.
(select-frame ',(selected-frame))
(tool--bar-here-mode -1))))))
next prev parent reply other threads:[~2004-10-08 19:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-07 7:51 pop-up tool-bar Drew Adams
2004-10-07 11:33 ` Miguel Frasson
2004-10-07 19:01 ` Drew Adams
2004-10-07 20:07 ` Stefan Monnier
2004-10-07 21:04 ` Drew Adams
2004-10-07 21:44 ` Drew Adams
2004-10-09 15:44 ` Richard Stallman
2004-10-10 19:15 ` Drew Adams
2004-10-08 17:20 ` Drew Adams
2004-10-08 17:39 ` Stefan
2004-10-08 18:24 ` David Kastrup
2004-10-08 19:58 ` Drew Adams
2004-10-08 19:03 ` Drew Adams [this message]
2004-10-08 23:12 ` Stefan Monnier
2004-10-09 0:46 ` Drew Adams
2004-10-11 4:45 ` Drew Adams
2004-10-07 20:08 ` David Kastrup
2004-10-07 20:20 ` Drew Adams
2004-10-07 20:54 ` Stefan Monnier
2004-10-07 20:56 ` David Kastrup
2004-10-08 6:12 ` Miguel Frasson
2004-10-09 15:45 ` Richard Stallman
2004-10-07 15:13 ` Stefan Monnier
2004-10-07 17:15 ` Drew Adams
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=FDELKNEBLPKKDCEBEJCBGEDLCIAA.drew.adams@oracle.com \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=frasson@altair.math.leidenuniv.nl \
/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 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.