git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] git-blame: Change installation instructions

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 7, 2007, 12:59 UTC
Message-ID
<200702071359.28100.jnareb@gmail.com>
In-Reply-To
<200702071356.43020.jnareb@gmail.com>

Change installation instructions to using either "(require 'git-blame)" or appropriate autoload instruction in GNU Emacs init file, .emacs This required adding "(provide 'git-blame)" at the end of git-blame.el and adding [preliminary] docstring to `git-blame-mode' function for consistency (to mark function as interactive in `autoload' we have to provide docstring as DOCSTRING is third arg, and INTERACTIVE fourth, and both are optional). `git-blame-mode' is marked to autoload.

While at it ensure that we add `git-blame-mode' to `minor-mode-alist' only once (in a way that does not depend on `cl' package).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 contrib/emacs/git-blame.el |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/contrib/emacs/git-blame.el b/contrib/emacs/git-blame.el
index cca0a77..7beeece 100644
--- a/contrib/emacs/git-blame.el
+++ b/contrib/emacs/git-blame.el
@@ -44,9 +44,20 @@
 
 ;;; Installation:
 ;;
-;;  1) Load into emacs: M-x load-file RET git-blame.el RET
-;;  2) Open a git-controlled file
-;;  3) Blame: M-x git-blame-mode
+;; To use this package, put it somewhere in `load-path' (or add
+;; directory with git-blame.el to `load-path'), and add the following
+;; line to your .emacs:
+;;
+;;    (require 'git-blame)
+;;
+;; If you do not want to load this package before it is necessary, you
+;; can make use of the `autoload' feature, e.g. by adding to your .emacs
+;; the following lines
+;;
+;;    (autoload 'git-blame-mode "git-blame"
+;;              "Minor mode for incremental blame for Git." t)
+;;
+;; Then first use of `M-x git-blame-mode' would load the package.
 
 ;;; Compatibility:
 ;;
@@ -102,9 +113,14 @@
 
 (defvar git-blame-mode nil)
 (make-variable-buffer-local 'git-blame-mode)
-(push (list 'git-blame-mode " blame") minor-mode-alist)
+(unless (assq 'git-blame-mode minor-mode-alist)
+  (setq minor-mode-alist
+	(cons (list 'git-blame-mode " blame")
+	      minor-mode-alist)))
 
+;;;###autoload
 (defun git-blame-mode (&optional arg)
+  "Minor mode for incremental blame for Git."
   (interactive "P")
   (if arg
       (setq git-blame-mode (eq arg 1))
@@ -244,4 +260,6 @@
    (format "git log -1 --pretty=oneline %s" (or hash
                                                 (git-blame-current-commit)))))
 
+(provide 'git-blame)
+
 ;;; git-blame.el ends here
-- 
1.4.4.4
Previous: Jakub Narebski
Message 2 of 2 in “git-blame: Add Emacs Lisp file headers and GNU GPL boilerplate”
  1. 1/2 git-blame: Add Emacs Lisp file headers and GNU GPL boilerplateJakub Narebski, Feb 7, 2007
  2. 2/2 git-blame: Change installation instructionsJakub Narebski, Feb 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.