From 18 Jan, 2021 0:00 UTC: All services will be temporary unavailable for maintenance
  • R/O
  • SSH

multi-project: Commit

Multi-project simplifies working with different projects in Emacs by providing support for creating, deleting, and searching with projects. Multi-project
supports interactively finding a file within a project by using a TAGS file.


Commit MetaInfo

Revision24708e6fb0c40234aed2c5aa0fec3c2e5ce096a9 (tree)
Zeit2017-12-18 05:11:44
AutorShawn Ellis <shawn.ellis17@gmai...>
CommiterShawn Ellis

Log Message

Enable multi-project with multi-project-mode instead of global-multi-project-mode. A recommendation from package-lint.

Ändern Zusammenfassung

Diff

diff -r f610b74567f3 -r 24708e6fb0c4 README.md
--- a/README.md Sun Nov 19 18:30:08 2017 -0200
+++ b/README.md Sun Dec 17 18:11:44 2017 -0200
@@ -10,9 +10,9 @@
1010
1111 ```elisp
1212 (require 'multi-project)
13-(global-multi-project-mode)
13+(multi-project-mode)
1414 ```
1515
1616 ## Switching Projects ##
1717
18-![Multi-project-recording.gif](https://bitbucket.org/repo/Rxnzy/images/1578877238-Multi-project-recording.gif)
\ No newline at end of file
18+![Multi-project-recording.gif](https://bitbucket.org/repo/Rxnzy/images/1578877238-Multi-project-recording.gif)
diff -r f610b74567f3 -r 24708e6fb0c4 multi-project.el
--- a/multi-project.el Sun Nov 19 18:30:08 2017 -0200
+++ b/multi-project.el Sun Dec 17 18:11:44 2017 -0200
@@ -4,9 +4,10 @@
44 ;; Copyright (C) 2010 - 2017
55
66 ;; Author: Shawn Ellis <shawn.ellis17@gmail.com>
7-;; Version: 0.0.25
7+;; Version: 0.0.26
8+;; Package-Requires: ((emacs "25"))
89 ;; URL: https://bitbucket.org/ellisvelo/multi-project/overview
9-;; Keywords: project management
10+;; Keywords: convenience project management
1011 ;;
1112
1213 ;; multi-project.el is free software; you can redistribute it and/or modify
@@ -35,7 +36,7 @@
3536 ;; To use multi-project add the following lines within your .emacs file:
3637 ;;
3738 ;; (require 'multi-project)
38-;; (global-multi-project-mode)
39+;; (multi-project-mode)
3940 ;;
4041 ;; The following bindings are created for multi-project
4142 ;; C-xpj - Project jump Displays a list of projects
@@ -101,7 +102,7 @@
101102 "The fuction to use when compiling a project."
102103 :group 'multi-project)
103104
104-(defvar multi-project-dir "~/.emacs.d/multi-project"
105+(defvar multi-project-dir (concat user-emacs-directory "multi-project")
105106 "Directory of the saved settings for multi-project.")
106107
107108 (defvar multi-project-file "mp"
@@ -117,10 +118,10 @@
117118 "The current selected project name.")
118119
119120 (defvar multi-project-history '()
120- "The history list of projects")
121+ "The history list of projects.")
121122
122123 (defvar multi-project-history-index 0
123- "Index for the project history")
124+ "Index for the project history.")
124125
125126 (defvar multi-project-overlay nil
126127 "Overlay used to highlight the current selection.")
@@ -147,7 +148,7 @@
147148 "Face for highlighting the currently selected file name."
148149 :group 'multi-project)
149150
150-(defvar global-multi-project-map
151+(defvar multi-project-mode-map
151152 (let ((map (make-sparse-keymap)))
152153 (define-key map (kbd "C-x pa") 'multi-project-anchor)
153154 (define-key map (kbd "C-x pi") 'multi-project-insert-path)
@@ -248,12 +249,14 @@
248249 (mapconcat 'identity (butlast (split-string file "/")) "/"))
249250
250251 (defun multi-project-compare-matches (dir lst)
252+ "Return the projects for DIR found in the working directories in LST."
251253 (let ((normalized-dir (abbreviate-file-name (directory-file-name dir))))
252254 (delq nil (mapcar (lambda (x) (if (string-equal normalized-dir
253255 (nth 1 x))
254256 x)) lst))))
255257
256258 (defun multi-project-filter-dir (dir lst)
259+ "Return the projects for DIR based upon the LST of working directories."
257260 (let ((project))
258261 (when (> (length dir) 0)
259262 (setq project (multi-project-compare-matches dir lst))
@@ -267,14 +270,13 @@
267270 (mapcar (lambda (x) (when (> (length x) 0) x)) lst)))
268271
269272 (defun multi-project-trim-string (lst)
270- "Removes whitespace from the beginning and end of the string."
273+ "Remove whitespace from the beginning and end of the string found within LST."
271274 (mapcar (lambda (x)
272275 (replace-regexp-in-string "\\`[ \t\n]*" "" (replace-regexp-in-string "[ \t\n]*\\'" "" x))) lst))
273276
274277
275278 (defun multi-project-find-by-directory ()
276- "Return the project list from the set of defined projects in
277-multi-projects-roots."
279+ "Return the project from the set of defined projects in 'multi-projects-roots."
278280 (multi-project-filter-dir default-directory multi-project-roots))
279281
280282
@@ -294,9 +296,11 @@
294296 result))
295297
296298 (defun multi-project-file-exists (project regexp)
299+ "Return true if the PROJECT constains a filename with a matching REGEXP."
297300 (directory-files (nth 1 project) nil regexp))
298301
299302 (defun multi-project-cmd (cmd)
303+ "Append .bat to CMD if executing under Windows."
300304 (let ((result cmd))
301305 (if (eq system-type 'windows-nt)
302306 (setq result (concat cmd ".bat")))
@@ -368,10 +372,7 @@
368372 (compile (multi-project-compile-prompt compile-command))))
369373
370374 (defun multi-project-find-root (parentDir childDir)
371- "Takes two directories as arguments and return the first
372-directory path that is different Argument PARENTDIR The parent
373-directory of the child. Argument CHILDDIR A directory found
374-under the parent."
375+ "Return the project root based upon the PARENTDIR and CHILDDIR."
375376 (interactive)
376377
377378 (let ((tlst (split-string childDir "[/\\]"))
@@ -405,7 +406,7 @@
405406 (replace-regexp-in-string "/$" "" directory))
406407
407408 (defun multi-project-remote-file (filename)
408- "Returns the FILENAME if it is remote and nil if it is local."
409+ "Return the FILENAME if it is remote and nil if it is local."
409410 (if (and (fboundp 'file-remote-p)
410411 (file-remote-p filename))
411412 filename
@@ -413,13 +414,6 @@
413414 (if (string-match "@?\\w+:" filename)
414415 filename)))
415416
416-(defun multi-project-remote-prefix (filename)
417- (if (multi-project-remote-file filename)
418- (if (fboundp 'file-remote-p)
419- (file-remote-p filename)
420- (if (string-match "\\(/.*@?\\w+:\\)+" filename)
421- (match-string 0 filename)))))
422-
423417 ;;;###autoload
424418 (defun multi-project-root ()
425419 "Jumps to the root of a project based upon current directory."
@@ -442,6 +436,7 @@
442436 (directory-file-name result)))
443437
444438 (defun multi-project-visit-tags (filename)
439+ "Visit the TAGS for FILENAME."
445440 (let ((tags-revert-without-query t))
446441 (visit-tags-table filename)))
447442
@@ -628,8 +623,7 @@
628623 (move-overlay multi-project-overlay (point-at-bol) (point-at-eol)))
629624
630625 (defun multi-project-move-selection (buf movefunc movearg)
631- "Move the selection marker to a new position in BUF determined
632-by MOVEFUNC and MOVEARG."
626+ "Move the selection marker to a new position in BUF determined by MOVEFUNC and MOVEARG."
633627 (unless (= (buffer-size (get-buffer buf)) 0)
634628 (save-selected-window
635629 (select-window (get-buffer-window buf))
@@ -668,7 +662,7 @@
668662 (quit-window))
669663
670664 (defun multi-project-switch (project-name &optional otherwindow)
671- "Switches to the project based upon the PROJECT_NAME"
665+ "Switch to the project based upon the PROJECT-NAME and optionally open OTHERWINDOW."
672666 (let ((project-list (multi-project-find-by-name project-name)))
673667 (setq multi-project-current-name (car project-list))
674668 (multi-project-change-tags (car project-list))
@@ -755,7 +749,7 @@
755749 (sort result (lambda (a b) (string< a b)))))
756750
757751 (defun multi-project-gtag-find-files (pattern)
758- "Find a list of files based upon a regular expression PATTERN using global."
752+ "Find a list of files based upon a regular expression PATTERN."
759753 (let ((mp-gtags-buffer (get-buffer-create "*mp-gtags*")))
760754 (with-current-buffer mp-gtags-buffer
761755 (erase-buffer)
@@ -846,8 +840,8 @@
846840
847841 ;;;###autoload
848842 (defun multi-project-find-file ()
849- "Search a TAGS file for a particular file that matches a user's
850-input."
843+ "Search a TAGS file for a particular file that match a user's input."
844+
851845 (interactive)
852846
853847 (let ((tags-revert-without-query t))
@@ -872,7 +866,7 @@
872866 ;;;###autoload
873867 (defadvice find-tag (before multi-project-find-tag
874868 (TAGNAME &optional NEXT-P REGEXP-P))
875- "Determine which TAGS file should be used based upon the current directory."
869+ "Find tag in project tags table based upon the current directory."
876870 (let ((project (multi-project-find-by-directory)))
877871 (when project
878872 (multi-project-change-tags (car project)))))
@@ -882,6 +876,7 @@
882876 (replace-regexp-in-string (concat directory "/?") "" filename))
883877
884878 (defun multi-project-create-tags-manually (project-dir project-tags)
879+ "Create a TAGS file based upon PROJECT-DIR and PROJECT-TAGS."
885880 (let* ((files (directory-files-recursively project-dir ".+"))
886881 (relative-files
887882 (mapcar (lambda (x) (file-relative-name x project-dir)) files)))
@@ -907,8 +902,8 @@
907902
908903
909904 (defun multi-project-create-tags (project-name project-directory project-tags)
910- "Creates a TAGS file based upon the the PROJECT-NAME and
911-PROJECT-DIRECTORY. The contents are written to PROJECT-TAGS."
905+ "Create a TAGS file based upon the the PROJECT-NAME and PROJECT-DIRECTORY.
906+The contents are written to PROJECT-TAGS."
912907
913908 (let ((buffer-name (concat "*" project-name "-TAGS*"))
914909 (etags-command
@@ -940,7 +935,7 @@
940935
941936
942937 (defun multi-project-recreate-tags ()
943- "Creats or re-creates the tags file based upon the project."
938+ "Create or re-create the TAGS file based upon the project."
944939 (interactive)
945940
946941 (let ((project (multi-project-dir-current)))
@@ -961,8 +956,7 @@
961956 (multi-project-change-tags (car project))))))
962957
963958 (defun multi-project-current ()
964- "Finds the project based upon the current project and then the
965-current directory."
959+ "Find the project based upon the current project and the current directory."
966960 (let ((result multi-project-current-name)
967961 (project))
968962 (unless result
@@ -972,8 +966,7 @@
972966 (multi-project-find-by-name result)))
973967
974968 (defun multi-project-dir-current ()
975- "Finds the project based upon the current directory and then
976-the current project."
969+ "Find the project based upon the current directory and the current project."
977970
978971 (let ((result (multi-project-find-by-directory)))
979972 (unless result
@@ -982,7 +975,7 @@
982975
983976 ;;;###autoload
984977 (defun multi-project-current-project ()
985- "Displays the current project in the minibuffer."
978+ "Display the current project in the minibuffer."
986979 (interactive)
987980 (let ((project (multi-project-current)))
988981 (if project
@@ -991,7 +984,7 @@
991984
992985
993986 (defun multi-project-visit-current-project ()
994- "Displays the current project in the minibuffer."
987+ "Display the current project in the minibuffer."
995988 (interactive)
996989 (let ((project (multi-project-current)))
997990 (when project
@@ -1000,9 +993,10 @@
1000993
1001994
1002995 (defun multi-project-compose-grep ()
1003- "Composes the grep command that ignores version control
1004-directories like .svn, .hg, and .git. If no version control
1005-directory is found, the default grep-find-command is returned"
996+ "Compose the grep command and ignore version control directories.
997+Directories like .svn, .hg, and .git will be ignored. If no
998+version control directory is found, the default
999+‘grep-find-command’ is returned"
10061000 (let ((grep-command)
10071001 (exclusion))
10081002 (cond ((file-exists-p ".hg")
@@ -1021,7 +1015,7 @@
10211015 grep-find-command)))
10221016
10231017 (defun multi-project-interactive-grep ()
1024- "Run grep-find interactively."
1018+ "Run ‘grep-find’ interactively."
10251019 (interactive)
10261020 (multi-project-root)
10271021
@@ -1040,10 +1034,10 @@
10401034
10411035 ;;;###autoload
10421036 (defun multi-project-shell ()
1043- "Creates a shell with the buffer name of the project. The
1044- function first looks if the current directory is within a known
1045- project. If no projects are found, then the current project is
1046- used."
1037+ "Create a shell with a buffer name of the project.
1038+The function first looks if the current directory is within a
1039+known project. If no projects are found, then the current
1040+project is used."
10471041 (interactive)
10481042
10491043 (let ((project (multi-project-dir-current)))
@@ -1070,11 +1064,12 @@
10701064
10711065
10721066 (defun multi-project-execute-tags-command (buffer-name etags-command)
1067+ "Generate a TAGS file in BUFFER-NAME for ETAGS-COMMAND."
10731068 (start-file-process-shell-command buffer-name (get-buffer buffer-name)
10741069 etags-command))
10751070
10761071 (defun multi-project-tramp-local-file (filename)
1077- "Returns the local filename if we have a remote file."
1072+ "Return the local filename if we have a remote FILENAME."
10781073 (cond ((and (fboundp 'file-remote-p)
10791074 (fboundp 'tramp-dissect-file-name)
10801075 (fboundp 'tramp-file-name-localname)
@@ -1089,8 +1084,7 @@
10891084 (t filename)))
10901085
10911086 (defun multi-project-create-tags-command (project-directory project-tags)
1092- "Provides the command to create the TAGS file based upon the
1093-PROJECT-DIRECTORY and PROJECT-TAGS."
1087+ "Return the tags command based upon PROJECT-DIRECTORY and PROJECT-TAGS."
10941088 (interactive)
10951089
10961090 (let ((local-project-directory
@@ -1140,7 +1134,7 @@
11401134
11411135 (setq project-list (list project-name project-directory project-subdir))
11421136
1143- (when (y-or-n-p "Use a TAGS file?")
1137+ (when (y-or-n-p "Use a TAGS file? ")
11441138 (let ((tags-file (concat project-directory "/TAGS")))
11451139
11461140 (setq project-tags (read-file-name "Project tags: " tags-file tags-file))
@@ -1268,7 +1262,7 @@
12681262 (multi-project-trim-string lst)))
12691263
12701264 (defun multi-project-delete-projects (projects)
1271- "Execute the action on the marked projects."
1265+ "Execute the action on the marked PROJECTS."
12721266 (when projects
12731267 (let ((current-point (point)))
12741268 (when (y-or-n-p (concat "Remove "
@@ -1284,6 +1278,7 @@
12841278 (multi-project-mark-line)))))
12851279
12861280 (defun multi-project-grep-project (project regex files)
1281+ "Execute grep on PROJECT based upon REGEX and FILES."
12871282 (let ((projectdir (nth 1 (multi-project-find-by-name project)))
12881283 (buffername (concat "*" project "-grep*")))
12891284
@@ -1297,7 +1292,8 @@
12971292 (rename-buffer buffername)))
12981293 buffername))
12991294
1300-(defun display-grep-buffers (bufferlist)
1295+(defun multi-project-display-grep-buffers (bufferlist)
1296+ "Display the grep results in BUFFERLIST."
13011297 (dolist (buffer bufferlist)
13021298 (set-window-buffer (split-window (get-largest-window)) buffer))
13031299 (balance-windows))
@@ -1315,7 +1311,7 @@
13151311
13161312
13171313 (defun multi-project-grep-projects (projects)
1318- "Execute the action on the marked projects."
1314+ "Execute the action on the marked PROJECTS."
13191315 (when projects
13201316 (let ((regex (multi-project-read-regexp))
13211317 (files (read-from-minibuffer "File pattern: " "*"))
@@ -1325,7 +1321,7 @@
13251321 (multi-project-grep-project project regex files)
13261322 bufferlist)))
13271323 (delete-other-windows)
1328- (display-grep-buffers bufferlist))))
1324+ (multi-project-display-grep-buffers bufferlist))))
13291325
13301326 (defun multi-project-execute-actions ()
13311327 "Execute the action on the marked projects."
@@ -1343,7 +1339,7 @@
13431339 (goto-char pos)
13441340 (multi-project-display-select))))
13451341
1346-(easy-menu-define multi-project-mode-menu global-multi-project-map
1342+(easy-menu-define multi-project-mode-menu multi-project-map
13471343 "'multi-project-mode' menu"
13481344 '("MP"
13491345 ["Jump to a project" multi-project-display-projects t]
@@ -1359,7 +1355,7 @@
13591355 ))
13601356
13611357 (defun multi-project-insert-path ()
1362- "Inserts the directory path of the current project."
1358+ "Insert the directory path of the current project."
13631359 (interactive)
13641360 (let ((project (multi-project-find-by-name multi-project-current-name)))
13651361 (when project
@@ -1367,14 +1363,14 @@
13671363
13681364
13691365 ;;;###autoload
1370-(define-minor-mode global-multi-project-mode
1366+(define-minor-mode multi-project-mode
13711367 "Toggle multi-project mode."
13721368 nil
13731369 " MP"
1374- global-multi-project-map
1370+ multi-project-mode-map
13751371 :global t
13761372 :group 'project
1377- (if global-multi-project-mode
1373+ (if multi-project-mode
13781374 (progn
13791375 (unless multi-project-roots
13801376 (multi-project-read-projects))
Show on old repository browser