* add a popup menu to toggle line-number-mode and column-number-mode
@ 2007-08-26 3:08 Dan Nicolaescu
2007-08-26 23:46 ` Juri Linkov
0 siblings, 1 reply; 4+ messages in thread
From: Dan Nicolaescu @ 2007-08-26 3:08 UTC (permalink / raw)
To: emacs-devel
The line number entry on the mode line is one of the very few that is
not mouse sensitive.
Adding a popup menu there that can be used to toggle line-number-mode
and column-number-mode seems very intuitive: set a property by
clicking on it's graphical representation.
Here's a proof of concept implementation. It am sure it can be
improved.
Opinions?
Index: bindings.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/bindings.el,v
retrieving revision 1.182
diff -c -3 -p -c -r1.182 bindings.el
*** bindings.el 13 Aug 2007 13:40:59 -0000 1.182
--- bindings.el 26 Aug 2007 02:48:26 -0000
*************** Keymap to display on major mode.")
*** 289,294 ****
--- 289,300 ----
map) "\
Keymap to display on minor modes.")
+ (defvar mode-line-column-line-mode-keymap
+ (let ((map (make-sparse-keymap)))
+ (define-key map [mode-line down-mouse-1] 'mode-line-column-line-number-menu-1)
+ map) "\
+ Keymap to display on for column and line number modes.")
+
(let* ((help-echo
;; The multi-line message doesn't work terribly well on the
;; bottom mode line... Better ideas?
*************** Keymap to display on minor modes.")
*** 332,346 ****
'mouse-2 #'mode-line-widen))
(propertize ")%]--" 'help-echo help-echo)))
(standard-mode-line-position
! `((-3 ,(propertize "%p" 'help-echo help-echo))
(size-indication-mode
(8 ,(propertize " of %I" 'help-echo help-echo)))
(line-number-mode
((column-number-mode
! (10 ,(propertize " (%l,%c)" 'help-echo help-echo))
! (6 ,(propertize " L%l" 'help-echo help-echo))))
((column-number-mode
! (5 ,(propertize " C%c" 'help-echo help-echo))))))))
(setq-default mode-line-format standard-mode-line-format)
(put 'mode-line-format 'standard-value
--- 338,364 ----
'mouse-2 #'mode-line-widen))
(propertize ")%]--" 'help-echo help-echo)))
(standard-mode-line-position
! `((-3 ,(propertize "%p"
! 'help-echo help-echo
! 'mouse-face 'mode-line-highlight
! 'local-map mode-line-column-line-mode-keymap))
(size-indication-mode
(8 ,(propertize " of %I" 'help-echo help-echo)))
(line-number-mode
((column-number-mode
! (10 ,(propertize " (%l,%c)"
! 'help-echo help-echo
! 'mouse-face 'mode-line-highlight
! 'local-map mode-line-column-line-mode-keymap))
! (6 ,(propertize " L%l"
! 'help-echo help-echo
! 'mouse-face 'mode-line-highlight
! 'local-map mode-line-column-line-mode-keymap))))
((column-number-mode
! (5 ,(propertize " C%c"
! 'help-echo help-echo
! 'mouse-face 'mode-line-highlight
! 'local-map mode-line-column-line-mode-keymap))))))))
(setq-default mode-line-format standard-mode-line-format)
(put 'mode-line-format 'standard-value
*************** Menu of mode operations in the mode line
*** 490,495 ****
--- 508,538 ----
(let ((indicator (car (nth 4 (car (cdr event))))))
(describe-minor-mode-from-indicator indicator)))
+ (defvar mode-line-column-line-number-menu
+ (make-sparse-keymap "Line and column number mode") "\
+ Menu to enable/disable the line and column numbers for the mode line.")
+
+ (define-key mode-line-column-line-number-menu [line-number-mode]
+ `(menu-item ,(purecopy "Display Line Numbers") line-number-mode
+ :button (:toggle . line-number-mode)))
+ (define-key mode-line-column-line-number-menu [column-number-mode]
+ `(menu-item ,(purecopy "Display Column Numbers") column-number-mode
+ :button (:toggle . column-number-mode)))
+
+ (defun mode-line-column-line-number-menu-1 (event)
+ (interactive "e")
+ (save-selected-window
+ (select-window (posn-window (event-start event)))
+ (let* ((selection (mode-line-column-line-number-menu event))
+ (binding (and selection (lookup-key mode-line-column-line-number-menu
+ (vector (car selection))))))
+ (if binding
+ (call-interactively binding)))))
+
+ (defun mode-line-column-line-number-menu (event)
+ (interactive "@e")
+ (x-popup-menu event mode-line-column-line-number-menu))
+
(defvar minor-mode-alist nil "\
Alist saying how to show minor modes in the mode line.
Each element looks like (VARIABLE STRING);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: add a popup menu to toggle line-number-mode and column-number-mode
2007-08-26 3:08 add a popup menu to toggle line-number-mode and column-number-mode Dan Nicolaescu
@ 2007-08-26 23:46 ` Juri Linkov
2007-08-27 0:03 ` Lennart Borgman (gmail)
0 siblings, 1 reply; 4+ messages in thread
From: Juri Linkov @ 2007-08-26 23:46 UTC (permalink / raw)
To: Dan Nicolaescu; +Cc: emacs-devel
> The line number entry on the mode line is one of the very few that is
> not mouse sensitive.
>
> Adding a popup menu there that can be used to toggle line-number-mode
> and column-number-mode seems very intuitive: set a property by
> clicking on it's graphical representation.
>
> Here's a proof of concept implementation. It am sure it can be improved.
>
> Opinions?
I recall there was an idea to bind mouse clicks on the line number to
`goto-line'.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: add a popup menu to toggle line-number-mode and column-number-mode
2007-08-26 23:46 ` Juri Linkov
@ 2007-08-27 0:03 ` Lennart Borgman (gmail)
[not found] ` <E1IPjAA-0003f7-R0@fencepost.gnu.org>
0 siblings, 1 reply; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2007-08-27 0:03 UTC (permalink / raw)
To: Juri Linkov; +Cc: Dan Nicolaescu, emacs-devel
Juri Linkov wrote:
>> The line number entry on the mode line is one of the very few that is
>> not mouse sensitive.
>>
>> Adding a popup menu there that can be used to toggle line-number-mode
>> and column-number-mode seems very intuitive: set a property by
>> clicking on it's graphical representation.
>>
>> Here's a proof of concept implementation. It am sure it can be improved.
>>
>> Opinions?
>
> I recall there was an idea to bind mouse clicks on the line number to
> `goto-line'.
They can of course be combined.
How about a more general module for popup menus where different modules
can register for popup menus. This could be bound to <apps> -- and
perhaps right click, since that is what users expect at least in most
w32 programs.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: add a popup menu to toggle line-number-mode and column-number-mode
[not found] ` <E1IPjAA-0003f7-R0@fencepost.gnu.org>
@ 2007-08-27 19:46 ` Lennart Borgman (gmail)
0 siblings, 0 replies; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2007-08-27 19:46 UTC (permalink / raw)
To: rms; +Cc: juri, dann, emacs-devel
Richard Stallman wrote:
> How about a more general module for popup menus where different modules
> can register for popup menus.
>
> It seems like creeping mechanism.
I wonder if you misunderstood me. Think of the case where different
minor modes and maybe the major mode want to add a popup menu. My
suggestion is to let them all do that but collect them in one popup menu.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-08-27 19:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-26 3:08 add a popup menu to toggle line-number-mode and column-number-mode Dan Nicolaescu
2007-08-26 23:46 ` Juri Linkov
2007-08-27 0:03 ` Lennart Borgman (gmail)
[not found] ` <E1IPjAA-0003f7-R0@fencepost.gnu.org>
2007-08-27 19:46 ` Lennart Borgman (gmail)
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).