unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: dmitry@gutov.dev, me@eshelyaron.com, 66317@debbugs.gnu.org
Subject: bug#66317: Project mode-line
Date: Wed, 04 Oct 2023 09:18:28 +0300	[thread overview]
Message-ID: <86il7mc3xr.fsf@mail.linkov.net> (raw)
In-Reply-To: <83zg0z6062.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 03 Oct 2023 21:17:09 +0300")

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

>> >>> This looks nice (I actually have something similar in my
>> >>> `mode-line-format` already), but I think that modifying
>> >>> `mode-line-format` when project.el is loaded is a bit problematic.
>> >>> Perhaps a better alternative would be to define a variable that holds
>> >>> this mode-line construct, along with an autoloaded function that people
>> >>> can call from their init files to actually add this construct to
>> >>> `mode-line-format`.  WDYT?
>> >> In bug#63469 I implemented 'project-mode' with the buffer-local
>> >> variable 'project-name'.  But due to objections I rewrote this
>> >> to simpler and direct implementation.  I could revive the previous
>> >> patch now.
>> >
>> > Could you make it a user option 'project-show-in-mode-line' or similar?
>> >
>> > Minor mode 'project-mode-line-mode' would also be okay.
>>
>> But there is no such mode for vc-mode (vc-mode is not a proper mode).
>
> I indeed think that an optional variable to control the mode-line
> additions would be better than a minor mode: this is too little
> functionality to justify a minor mode.

Ok, here is the implementation with an optional variable:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: project-mode-line.patch --]
[-- Type: text/x-diff, Size: 1579 bytes --]

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 2e6ae89a443..74b2347b715 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -2010,5 +2103,36 @@ project-uniquify-dirname-transform
           (file-relative-name dirname root))))
     dirname))
 
+;;; Project mode-line
+
+;;;###autoload
+(defcustom project-mode-line nil
+  "Show the current project name with the menu on the mode line."
+  :type 'boolean
+  :group 'project
+  :version "30.1")
+
+(defvar project-menu-entry
+  `(menu-item "Project" ,menu-bar-project-menu))
+
+(defvar project-mode-line-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map [mode-line down-mouse-1] project-menu-entry)
+    map))
+
+(defvar project-mode-line-format '(:eval (project-mode-line-format)))
+(put 'project-mode-line-format 'risky-local-variable t)
+
+(defun project-mode-line-format ()
+  "Compose the project mode-line."
+  (when-let ((project (project-current)))
+    (concat
+     " "
+     (propertize
+      (project-name project)
+      'mouse-face 'mode-line-highlight
+      'help-echo "mouse-1: Project menu"
+      'local-map project-mode-line-map))))
+
 (provide 'project)
 ;;; project.el ends here
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 207adb3a2a4..70e4087e131 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -682,6 +682,7 @@ mode-line-end-spaces
 	     'mode-line-buffer-identification
 	     "   "
 	     'mode-line-position
+	     '(project-mode-line project-mode-line-format)
 	     '(vc-mode vc-mode)
 	     "  "
 	     'mode-line-modes

  reply	other threads:[~2023-10-04  6:18 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03  6:29 bug#66317: Project mode-line Juri Linkov
2023-10-03  8:07 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-03 16:24   ` Dmitry Gutov
2023-10-03 17:11   ` Juri Linkov
2023-10-03 17:51     ` Dmitry Gutov
2023-10-03 17:58       ` Juri Linkov
2023-10-03 18:04         ` Dmitry Gutov
2023-10-03 18:17         ` Eli Zaretskii
2023-10-04  6:18           ` Juri Linkov [this message]
2023-10-04  7:15             ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-04 17:06               ` Juri Linkov
2023-10-05 20:03                 ` Spencer Baugh
2023-10-05 20:16                   ` Dmitry Gutov
2023-10-06  6:46                   ` Juri Linkov
2023-10-09 18:45                 ` Juri Linkov
2023-10-09 18:57                   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-10  6:56                     ` Juri Linkov
2023-10-10 11:46                       ` Dmitry Gutov
2023-10-11  6:27                         ` Juri Linkov
2023-10-04  7:43             ` Eli Zaretskii
2023-10-04 14:34               ` Dmitry Gutov
2023-10-04 17:04               ` Juri Linkov
2023-10-05 20:23             ` Dmitry Gutov
2023-10-06  4:50               ` Eli Zaretskii
2023-10-06  6:44                 ` Juri Linkov
2023-10-06 10:20                   ` Dmitry Gutov
2023-10-09 18:10                     ` Juri Linkov
2023-10-09 18:22                       ` Dmitry Gutov
2023-10-09 18:48                         ` Juri Linkov
2023-10-09 18:52                           ` Dmitry Gutov
2023-10-10  6:50                             ` Juri Linkov
2023-10-10  7:10                               ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-10  7:18                                 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-10 10:45                                 ` Dmitry Gutov
2023-10-10 11:34                                   ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-10 11:42                                     ` Dmitry Gutov
2023-10-20  9:01             ` Ihor Radchenko
2023-10-20 15:52               ` Dmitry Gutov
2023-10-31  7:34                 ` Juri Linkov
2023-11-01  2:03                   ` Dmitry Gutov
2023-11-01  7:32                     ` Juri Linkov
2023-10-03 12:06 ` Stefan Kangas
2023-10-15 22:42 ` sbaugh
2023-10-16  0:57   ` Dmitry Gutov
2023-10-16 17:01     ` Juri Linkov
2023-10-16 19:12       ` Eli Zaretskii
2023-10-18 17:20         ` Juri Linkov
2023-10-18 18:41           ` Dmitry Gutov
2023-10-19  6:40             ` Juri Linkov
2023-10-19 11:23               ` Dmitry Gutov
2023-10-23 17:23                 ` Juri Linkov
2023-10-24 23:48                   ` Dmitry Gutov
2023-10-18 18:55       ` Dmitry Gutov

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86il7mc3xr.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=66317@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=eliz@gnu.org \
    --cc=me@eshelyaron.com \
    /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 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).