From f815ea7795ac4c84804c58ed32aff679f8bb410e Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Mon, 21 Feb 2022 18:28:00 +0100 Subject: Disband magit-imenu.el Now that the code that was used to support magit-mode-derived modes has mostly evaporated, it is okay to spread the little code that is necessary to support other modes across the respective files. --- default.mk | 1 - lisp/Makefile | 1 - lisp/git-rebase.el | 18 ++++++++++ lisp/magit-imenu.el | 96 ------------------------------------------------- lisp/magit-repos.el | 17 +++++++++ lisp/magit-submodule.el | 14 ++++++++ lisp/magit.el | 1 - 7 files changed, 49 insertions(+), 99 deletions(-) delete mode 100644 lisp/magit-imenu.el diff --git a/default.mk b/default.mk index 479225a..bbfdbbf 100644 --- a/default.mk +++ b/default.mk @@ -98,7 +98,6 @@ ELS += magit-gitignore.el ELS += magit-bundle.el ELS += magit-extras.el ELS += git-rebase.el -ELS += magit-imenu.el ELS += magit-bookmark.el ELCS = $(ELS:.el=.elc) ELMS = magit.el $(filter-out $(addsuffix .el,$(PACKAGES)),$(ELS)) diff --git a/lisp/Makefile b/lisp/Makefile index 065297c..4c764fb 100644 --- a/lisp/Makefile +++ b/lisp/Makefile @@ -63,7 +63,6 @@ magit-sparse-checkout.elc: magit.elc magit-bundle.elc: magit.elc magit-extras.elc: magit.elc magit-merge.elc git-rebase.elc: magit.elc -magit-imenu.elc: magit.elc git-rebase.elc magit-bookmark.elc: magit.elc magit-obsolete.elc: magit.elc diff --git a/lisp/git-rebase.el b/lisp/git-rebase.el index a893a64..886156b 100644 --- a/lisp/git-rebase.el +++ b/lisp/git-rebase.el @@ -828,6 +828,24 @@ By default, this is the same except for the \"pick\" command." (add-to-list 'with-editor-file-name-history-exclude git-rebase-filename-regexp) +;;; Imenu Support + +(defun magit-imenu--rebase-prev-index-position-function () + "Move point to previous commit in git-rebase buffer. +Used as a value for `imenu-prev-index-position-function'." + (catch 'found + (while (not (bobp)) + (git-rebase-backward-line) + (when (git-rebase-line-p) + (throw 'found t))))) + +(defun magit-imenu--rebase-extract-index-name-function () + "Return imenu name for line at point. +Point should be at the beginning of the line. This function +is used as a value for `imenu-extract-index-name-function'." + (buffer-substring-no-properties (line-beginning-position) + (line-end-position))) + ;;; _ (provide 'git-rebase) ;;; git-rebase.el ends here diff --git a/lisp/magit-imenu.el b/lisp/magit-imenu.el deleted file mode 100644 index aef6175..0000000 --- a/lisp/magit-imenu.el +++ /dev/null @@ -1,96 +0,0 @@ -;;; magit-imenu.el --- Integrate Imenu in magit major modes -*- lexical-binding: t -*- - -;; Copyright (C) 2010-2022 The Magit Project Contributors -;; -;; You should have received a copy of the AUTHORS.md file which -;; lists all contributors. If not, see http://magit.vc/authors. - -;; Author: Damien Cassou -;; Maintainer: Jonas Bernoulli - -;; SPDX-License-Identifier: GPL-3.0-or-later - -;; Magit is free software; you can redistribute it and/or modify it -;; under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. -;; -;; Magit is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -;; License for more details. -;; -;; You should have received a copy of the GNU General Public License -;; along with Magit. If not, see http://www.gnu.org/licenses. - -;;; Commentary: - -;; Emacs' major modes can facilitate navigation in their buffers by -;; supporting Imenu. In such major modes, launching Imenu (M-x imenu) -;; makes Emacs display a list of items (e.g., function definitions in -;; a programming major mode). Selecting an item from this list moves -;; point to this item. - -;;; Code: - -(require 'magit) -(require 'git-rebase) - -;;; Submodule list mode - -;;;###autoload -(defun magit-imenu--submodule-prev-index-position-function () - "Move point to previous line in magit-submodule-list buffer. -Used as a value for `imenu-prev-index-position-function'." - (unless (bobp) - (forward-line -1))) - -;;;###autoload -(defun magit-imenu--submodule-extract-index-name-function () - "Return imenu name for line at point. -Point should be at the beginning of the line. This function -is used as a value for `imenu-extract-index-name-function'." - (car (tabulated-list-get-entry))) - -;;; Repolist mode - -;;;###autoload -(defun magit-imenu--repolist-prev-index-position-function () - "Move point to previous line in magit-repolist buffer. -Used as a value for `imenu-prev-index-position-function'." - (unless (bobp) - (forward-line -1))) - -;;;###autoload -(defun magit-imenu--repolist-extract-index-name-function () - "Return imenu name for line at point. -Point should be at the beginning of the line. This function -is used as a value for `imenu-extract-index-name-function'." - (let ((entry (tabulated-list-get-entry))) - (format "%s (%s)" - (car entry) - (car (last entry))))) - -;;; Rebase mode - -;;;###autoload -(defun magit-imenu--rebase-prev-index-position-function () - "Move point to previous commit in git-rebase buffer. -Used as a value for `imenu-prev-index-position-function'." - (catch 'found - (while (not (bobp)) - (git-rebase-backward-line) - (when (git-rebase-line-p) - (throw 'found t))))) - -;;;###autoload -(defun magit-imenu--rebase-extract-index-name-function () - "Return imenu name for line at point. -Point should be at the beginning of the line. This function -is used as a value for `imenu-extract-index-name-function'." - (buffer-substring-no-properties (line-beginning-position) - (line-end-position))) - -;;; _ -(provide 'magit-imenu) -;;; magit-imenu.el ends here diff --git a/lisp/magit-repos.el b/lisp/magit-repos.el index d99373a..efd8147 100644 --- a/lisp/magit-repos.el +++ b/lisp/magit-repos.el @@ -469,6 +469,23 @@ which only lists the first one found." (number-to-string n)) (if (> n (or (cadr (assq :normal-count spec)) 0)) 'bold 'shadow))) +;;;; Imenu Support + +(defun magit-imenu--repolist-prev-index-position-function () + "Move point to previous line in magit-repolist buffer. +Used as a value for `imenu-prev-index-position-function'." + (unless (bobp) + (forward-line -1))) + +(defun magit-imenu--repolist-extract-index-name-function () + "Return imenu name for line at point. +Point should be at the beginning of the line. This function +is used as a value for `imenu-extract-index-name-function'." + (let ((entry (tabulated-list-get-entry))) + (format "%s (%s)" + (car entry) + (car (last entry))))) + ;;; Read Repository (defun magit-read-repository (&optional read-directory-name) diff --git a/lisp/magit-submodule.el b/lisp/magit-submodule.el index ffd2c82..e818ce6 100644 --- a/lisp/magit-submodule.el +++ b/lisp/magit-submodule.el @@ -684,6 +684,20 @@ These sections can be expanded to show the respective commits." "Insert the relative path of the submodule." (cadr (assq :path spec))) +;;;; Imenu Support + +(defun magit-imenu--submodule-prev-index-position-function () + "Move point to previous line in magit-submodule-list buffer. +Used as a value for `imenu-prev-index-position-function'." + (unless (bobp) + (forward-line -1))) + +(defun magit-imenu--submodule-extract-index-name-function () + "Return imenu name for line at point. +Point should be at the beginning of the line. This function +is used as a value for `imenu-extract-index-name-function'." + (car (tabulated-list-get-entry))) + ;;; Utilities (defun magit-submodule--maybe-reuse-gitdir (name path) diff --git a/lisp/magit.el b/lisp/magit.el index f36f864..99374af 100644 --- a/lisp/magit.el +++ b/lisp/magit.el @@ -660,7 +660,6 @@ For X11 something like ~/.xinitrc should work.\n" (require 'magit-sparse-checkout) (require 'magit-extras) (require 'git-rebase) - (require 'magit-imenu) (require 'magit-bookmark))) (with-eval-after-load 'bookmark -- cgit v1.0