unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Add project-name function
@ 2021-03-05 22:48 Ivan Sokolov
  2021-03-06 14:10 ` Philip Kaludercic
  0 siblings, 1 reply; 5+ messages in thread
From: Ivan Sokolov @ 2021-03-05 22:48 UTC (permalink / raw)
  To: emacs-devel

[-- 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


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

end of thread, other threads:[~2021-03-06 20:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 22:48 Add project-name function Ivan Sokolov
2021-03-06 14:10 ` Philip Kaludercic
2021-03-06 20:22   ` Dmitry Gutov
2021-03-06 20:51     ` Ivan Sokolov
2021-03-06 20:53     ` Add " Ivan Sokolov

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