From: Ivan Sokolov <ivan-p-sokolov@ya.ru>
To: emacs-devel@gnu.org
Subject: Add project-name function
Date: Sat, 06 Mar 2021 01:48:56 +0300 [thread overview]
Message-ID: <877dmltdwn.fsf@ya.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 71 bytes --]
I hope I am doing everything right, this is my first patch for Emacs.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-progmodes-project.el-Add-project-name.patch --]
[-- Type: text/x-patch, Size: 2536 bytes --]
From 0aa1b0417f2fd4f8fdef24194c55304611711cfa Mon Sep 17 00:00:00 2001
From: Ivan Sokolov <ivan-p-sokolov@ya.ru>
Date: Sat, 6 Mar 2021 01:43:30 +0300
Subject: [PATCH] lisp/progmodes/project.el: Add 'project-name'
---
lisp/progmodes/project.el | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index abe563bec0..3abae8606f 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -888,6 +888,13 @@ PREDICATE, HIST, and DEFAULT have the same meaning as in
(interactive)
(vc-dir (project-root (project-current t))))
+;;;###autoload
+(defun project-name (project)
+ "Return PROJECT's name."
+ (file-name-nondirectory
+ (directory-file-name
+ (project-root project))))
+
;;;###autoload
(defun project-shell ()
"Start an inferior shell in the current project's root directory.
@@ -896,12 +903,10 @@ switch to it. Otherwise, create a new shell buffer.
With \\[universal-argument] prefix arg, create a new inferior shell buffer even
if one already exists."
(interactive)
- (let* ((default-directory (project-root (project-current t)))
+ (let* ((project (project-current t))
+ (default-directory (project-root project))
(default-project-shell-name
- (concat "*" (file-name-nondirectory
- (directory-file-name
- (file-name-directory default-directory)))
- "-shell*"))
+ (concat "*" (project-name project) "-shell*"))
(shell-buffer (get-buffer default-project-shell-name)))
(if (and shell-buffer (not current-prefix-arg))
(pop-to-buffer shell-buffer)
@@ -916,12 +921,10 @@ With \\[universal-argument] prefix arg, create a new Eshell buffer even
if one already exists."
(interactive)
(defvar eshell-buffer-name)
- (let* ((default-directory (project-root (project-current t)))
+ (let* ((project (project-current t))
+ (default-directory (project-root project))
(eshell-buffer-name
- (concat "*" (file-name-nondirectory
- (directory-file-name
- (file-name-directory default-directory)))
- "-eshell*"))
+ (concat "*" (project-name project) "-eshell*"))
(eshell-buffer (get-buffer eshell-buffer-name)))
(if (and eshell-buffer (not current-prefix-arg))
(pop-to-buffer eshell-buffer)
base-commit: ba33089d50a4f74b88cd7fc9d862d183d096c27d
--
2.30.1
next reply other threads:[~2021-03-05 22:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-05 22:48 Ivan Sokolov [this message]
2021-03-06 14:10 ` Add project-name function Philip Kaludercic
2021-03-06 20:22 ` Dmitry Gutov
2021-03-06 20:51 ` Ivan Sokolov
2021-03-06 20:53 ` Add " Ivan Sokolov
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=877dmltdwn.fsf@ya.ru \
--to=ivan-p-sokolov@ya.ru \
--cc=emacs-devel@gnu.org \
/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).