unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Line Numbers and the Options Menu
@ 2017-07-13 11:33 Michael Albinus
  2017-07-13 16:05 ` Eli Zaretskii
  2017-07-14  6:18 ` Alex
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Albinus @ 2017-07-13 11:33 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 168 bytes --]

Hi,

now that we have `display-line-numbers', I propose to offer its setting
in the Options Menu. Any objection to install the appended patch?

Best regards, Michael.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: *vc-diff* --]
[-- Type: text/x-patch, Size: 2701 bytes --]

diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 3ca7d1b..612ea65 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1202,6 +1202,50 @@ menu-bar-showhide-menu
                                                  'tool-bar-lines))))))
     menu))

+(defvar menu-bar-line-numbers-menu
+  (let ((menu (make-sparse-keymap "Line Numbers")))
+
+    (bindings--define-key menu [visual]
+      `(menu-item "Visual Line Numbers"
+                  ,(lambda ()
+                     (interactive)
+                     (setq display-line-numbers 'visual)
+                     (message "Visual line numbers enabled"))
+                  :help "Enable visual line numbers"
+                  :button (:radio . (eq display-line-numbers 'visual))
+                  :visible (menu-bar-menu-frame-live-and-visible-p)))
+
+    (bindings--define-key menu [relative]
+      `(menu-item "Relative Line Numbers"
+                  ,(lambda ()
+                     (interactive)
+                     (setq display-line-numbers 'relative)
+                     (message "Relative line numbers enabled"))
+                  :help "Enable relative line numbers"
+                  :button (:radio . (eq display-line-numbers 'relative))
+                  :visible (menu-bar-menu-frame-live-and-visible-p)))
+
+    (bindings--define-key menu [absolute]
+      `(menu-item "Absolute Line Numbers"
+                  ,(lambda ()
+                     (interactive)
+                     (setq display-line-numbers t)
+                     (message "Absolute line numbers enabled"))
+                  :help "Enable absolute line numbers"
+                  :button (:radio . (eq display-line-numbers t))
+                  :visible (menu-bar-menu-frame-live-and-visible-p)))
+
+    (bindings--define-key menu [none]
+      `(menu-item "No Line Numbers"
+                  ,(lambda ()
+                     (interactive)
+                     (setq display-line-numbers nil)
+                     (message "Line numbers disabled"))
+                  :help "Disable line numbers"
+                  :button (:radio . (null display-line-numbers))
+                  :visible (menu-bar-menu-frame-live-and-visible-p)))
+    menu))
+
 (defvar menu-bar-line-wrapping-menu
   (let ((menu (make-sparse-keymap "Line Wrapping")))

@@ -1408,6 +1452,10 @@ menu-bar-options-menu
       `(menu-item "Default Search Options"
 		  ,menu-bar-search-options-menu))

+    (bindings--define-key menu [line-numbers]
+      `(menu-item "Line Numbers in This Buffer"
+		  ,menu-bar-line-numbers-menu))
+
     (bindings--define-key menu [line-wrapping]
       `(menu-item "Line Wrapping in This Buffer"
 		  ,menu-bar-line-wrapping-menu))

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Line Numbers and the Options Menu
  2017-07-13 11:33 Line Numbers and the Options Menu Michael Albinus
@ 2017-07-13 16:05 ` Eli Zaretskii
  2017-07-14  6:18 ` Alex
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2017-07-13 16:05 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

> From: Michael Albinus <michael.albinus@gmx.de>
> Date: Thu, 13 Jul 2017 13:33:34 +0200
> 
> now that we have `display-line-numbers', I propose to offer its setting
> in the Options Menu.

If you do that, please delete the one under Hide/Show.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Line Numbers and the Options Menu
  2017-07-13 11:33 Line Numbers and the Options Menu Michael Albinus
  2017-07-13 16:05 ` Eli Zaretskii
@ 2017-07-14  6:18 ` Alex
  2017-07-14  8:13   ` Michael Albinus
  1 sibling, 1 reply; 4+ messages in thread
From: Alex @ 2017-07-14  6:18 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

Michael Albinus <michael.albinus@gmx.de> writes:

> Hi,
>
> now that we have `display-line-numbers', I propose to offer its setting
> in the Options Menu. Any objection to install the appended patch?
>
> Best regards, Michael.

Hi,

I personally don't use the Options menu in these situations, but I
figure I should comment since I'm making a minor mode interface for
`display-line-numbers' (see the thread starting from [1]).

Firstly, I think that it makes more sense to put this inside of the
Show/Hide submenu.

Secondly, it might be nicer to use the (hopefully) upcoming mode
interface for the menu for the following reasons:

1) The other entries in the menu appear to enable/disable features
globally.

2) The other entries appear to allow for specific buffers to
enable/disable the feature apart from the menu-bar (without them
menu-bar overwriting the buffer's customization).

Feel free to not use it though.

Here's something I quickly tested out which may help if you choose to
use the mode, which I believe satisfies the above. It would replace your
lambda expressions.

(defun menu-bar-display-line-numbers-mode (type)
  (require 'display-line-numbers)
  (setq-default display-line-numbers-type type)
  (if type
      (if global-display-line-numbers-mode
          (dolist (b (buffer-list))
            (with-current-buffer b
              (when display-line-numbers-mode
                (setq display-line-numbers type))))
        (global-display-line-numbers-mode))
    (global-display-line-numbers-mode -1)))


Footnotes: [1]
https://lists.gnu.org/archive/html/emacs-devel/2017-07/msg00275.html




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Line Numbers and the Options Menu
  2017-07-14  6:18 ` Alex
@ 2017-07-14  8:13   ` Michael Albinus
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Albinus @ 2017-07-14  8:13 UTC (permalink / raw)
  To: Alex; +Cc: emacs-devel

Alex <agrambot@gmail.com> writes:

> Hi,

Hi Alex,

> Firstly, I think that it makes more sense to put this inside of the
> Show/Hide submenu.

Agreed. I've updated the patch.

> Secondly, it might be nicer to use the (hopefully) upcoming mode
> interface for the menu for the following reasons:

No problem, my patch could wait. If your minor mode reaches Emecs next
days: fine. If not, there's still time to apply my patch.

Release of Emacs 26.1 won't happen immediately, I suspect.

Best regards, Michael.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-14  8:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-13 11:33 Line Numbers and the Options Menu Michael Albinus
2017-07-13 16:05 ` Eli Zaretskii
2017-07-14  6:18 ` Alex
2017-07-14  8:13   ` Michael Albinus

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).