branch: master commit 8ad82e5308ded892a379cb81b470b24285e58cc0 Merge: a0ac02f 4d1dcdf Author: rocky <ro...@gnu.org> Commit: rocky <ro...@gnu.org>
Merge commit '4d1dcdf7631c23b1259ad4f72bf9686cf95fb46c' Conflicts: packages/loc-changes/loc-changes.el --- packages/loc-changes/el-get-install.el | 104 +++++++++++++++++++++++++++++ packages/loc-changes/loc-changes.el | 48 ++++++------- packages/loc-changes/test/Makefile.am | 2 +- packages/loc-changes/test/install-pkgs.el | 24 ------- 4 files changed, 130 insertions(+), 48 deletions(-) diff --git a/packages/loc-changes/el-get-install.el b/packages/loc-changes/el-get-install.el new file mode 100644 index 0000000..86c55ec --- /dev/null +++ b/packages/loc-changes/el-get-install.el @@ -0,0 +1,104 @@ +(eval-when-compile + (defvar el-get-sources) +) + +(declare-function el-get-post-install 'el-get) + +(add-to-list 'load-path "~/.emacs.d/el-get/el-get") + +;;; el-get-install.el --- installer for the lazy +;; +;; Copyright (C) 2010 Dimitri Fontaine +;; +;; Author: Dimitri Fontaine <d...@tapoueh.org> +;; URL: http://www.emacswiki.org/emacs/el-get.el +;; Created: 2010-06-17 +;; Keywords: emacs package elisp install elpa git git-svn bzr cvs apt-get fink http http-tar +;; Licence: WTFPL, grab your copy here: http://sam.zoy.org/wtfpl/ +;; +;; This file is NOT part of GNU Emacs. +;; +;; bootstrap your el-get installation, the goal is then to use el-get to +;; update el-get. +;; +;; So the idea is that you copy/paste this code into your *scratch* buffer, +;; hit C-j, and you have a working el-get. + +(let ((el-get-root + (file-name-as-directory + (or (bound-and-true-p el-get-dir) + (concat (file-name-as-directory user-emacs-directory) "el-get"))))) + + (when (file-directory-p el-get-root) + (add-to-list 'load-path el-get-root)) + + ;; try to require el-get, failure means we have to install it + (unless (require 'el-get nil t) + (unless (file-directory-p el-get-root) + (make-directory el-get-root t)) + + (let* ((package "el-get") + (buf (switch-to-buffer "*el-get bootstrap*")) + (pdir (file-name-as-directory (concat el-get-root package))) + (git (or (executable-find "git") + (error "Unable to find `git'"))) + (url (or (bound-and-true-p el-get-git-install-url) + "http://github.com/dimitri/el-get.git")) + (default-directory el-get-root) + (process-connection-type nil) ; pipe, no pty (--no-progress) + + ;; First clone el-get + (status + (call-process + git nil `(,buf t) t "--no-pager" "clone" "-v" url package))) + + (unless (zerop status) + (error "Couldn't clone el-get from the Git repository: %s" url)) + + ;; switch branch if we have to + (let* ((branch (cond + ;; Check if a specific branch is requested + ((bound-and-true-p el-get-install-branch)) + ;; Check if master branch is requested + ((boundp 'el-get-master-branch) "master") + ;; Read the default branch from the el-get recipe + ((plist-get (with-temp-buffer + (insert-file-contents-literally + (expand-file-name "recipes/el-get.rcp" pdir)) + (read (current-buffer))) + :branch)) + ;; As a last resort, use the master branch + ("master"))) + (remote-branch (format "origin/%s" branch)) + (default-directory pdir) + (bstatus + (if (string-equal branch "master") + 0 + (call-process git nil (list buf t) t "checkout" "-t" remote-branch)))) + (unless (zerop bstatus) + (error "Couldn't `git checkout -t %s`" branch))) + + (add-to-list 'load-path pdir) + (load package) + (let ((el-get-default-process-sync t) ; force sync operations for installer + (el-get-verbose t)) ; let's see it all + (el-get-post-install "el-get")) + (with-current-buffer buf + (goto-char (point-max)) + (insert "\nCongrats, el-get is installed and ready to serve!"))))) + + +(declare-function el-get 'el-get) + +;; now either el-get is `require'd already, or have been `load'ed by the +;; el-get installer. +(setq + el-get-sources + '(el-get ; el-get is self-hosting + loc-changes ; loc marks in buffers + load-relative ; load emacs lisp relative to emacs source + test-simple ; simple test framework + )) + +;; install new packages and init already installed packages +(el-get 'sync '(loc-changes list-utils load-relative test-simple)) diff --git a/packages/loc-changes/loc-changes.el b/packages/loc-changes/loc-changes.el index b514b27..4e3660b 100644 --- a/packages/loc-changes/loc-changes.el +++ b/packages/loc-changes/loc-changes.el @@ -1,6 +1,6 @@ ;;; loc-changes.el --- keep track of positions even after buffer changes -;; Copyright (C) 2015 Free Software Foundation, Inc +;; Copyright (C) 2015, 2016 Free Software Foundation, Inc ;; Author: Rocky Bernstein <ro...@gnu.org> ;; Version: 1.2 @@ -35,17 +35,19 @@ ;;; Code: +(eval-when-compile (require 'cl)) + (make-variable-buffer-local 'loc-changes-alist) (defvar loc-changes-alist '() "A buffer-local association-list (alist) of line numbers and -their corresponding markers in the buffer. The key is the line number; the value -the marker" - ) +their corresponding markers in the buffer. The key is the line +number; the a list of value the marker and the initial 10 +characters after that mark" ) (defun loc-changes:follow-mark(event) (interactive "e") (let* ((pos (posn-point (event-end event))) - (mark (get-text-property pos 'mark))) + (mark (car (get-text-property pos 'mark)))) (switch-to-buffer-other-window (marker-buffer mark)) (goto-char (marker-position mark)) )) @@ -68,17 +70,17 @@ internal buffer called *Describe*." (dolist (assoc alist) (put-text-property (insert-text-button - (format "line %d: %s\n" (car assoc) (cdr assoc)) + (format "line %d: %s" (car assoc) (cadr assoc)) 'action 'loc-changes:follow-mark 'help-echo "mouse-2: go to this location") (point) 'mark (cdr assoc) ) + (insert (format ":\t%s\n" (cl-caddr assoc))) ) (setq buffer-read-only 't) )) -;;;###autoload (defun loc-changes-goto-line (line-number &optional column-number) "Position `point' at LINE-NUMBER of the current buffer. If COLUMN-NUMBER is given, position `point' at that column just @@ -87,7 +89,7 @@ the line starts at column 0, so the column number display will be one less than COLUMN-NUMBER. For example COLUMN-NUMBER 1 will set before the first column on the line and show 0. -The Emacs `goto-line' docstring says it is the wrong to use that +The Emacs `goto-line' docstring says it is wrong to use that function in a Lisp program. So here is something that I proclaim is okay to use in a Lisp program." (interactive @@ -155,9 +157,9 @@ is okay to use in a Lisp program." "Add an element `loc-changes-alist'. The car will be POS and a marker for it will be created at the point." (setq loc-changes-alist - (cons (cons pos (point-marker)) loc-changes-alist))) + (cons (cons pos (list (point-marker) (buffer-substring (point) (point-at-eol)))) + loc-changes-alist))) -;;;###autoload (defun loc-changes-add-and-goto (line-number &optional opt-buffer) "Add a marker at LINE-NUMBER and record LINE-NUMBER and its marker association in `loc-changes-alist'." @@ -194,7 +196,6 @@ marker association in `loc-changes-alist'." )) ) -;;;###autoload (defun loc-changes-clear-buffer (&optional opt-buffer) "Remove all location-tracking associations in BUFFER." (interactive "bbuffer: ") @@ -205,7 +206,6 @@ marker association in `loc-changes-alist'." )) ) -;;;###autoload (defun loc-changes-reset-position (&optional opt-buffer no-insert) "Update `loc-changes-alist' so that the line number of point is used to when aline number is requested. @@ -223,7 +223,8 @@ so that its positions are will be reflected." ) (with-current-buffer buffer (if elt - (setcdr elt (point)) + (setcdr elt + (list (point-marker) (buffer-substring (point) (point-at-eol)))) (unless no-insert (loc-changes-add-elt line-number) ) @@ -232,23 +233,24 @@ so that its positions are will be reflected." )) -(defun loc-changes-goto (position &optional opt-buffer no-update) - "Go to the position inside BUFFER taking into account the -previous location marks. Normally if the position hasn't been -seen before, we will add a new mark for this position. However if +(defun loc-changes-goto (line-number &optional opt-buffer no-update) + "Go to the LINE-NUMBER inside OPT-BUFFER taking into account the +previous line-number marks. Normally if the line-number hasn't been +seen before, we will add a new mark for this line-number. However if NO-UPDATE is set, no mark is added." - (unless (wholenump position) + ;;; FIXME: opt-buffer is not used + (unless (wholenump line-number) (error "Expecting line-number parameter `%s' to be a whole number" - position)) - (let ((elt (assq position loc-changes-alist))) + line-number)) + (let ((elt (assq line-number loc-changes-alist))) (if elt - (let ((marker (cdr elt))) + (let ((marker (cadr elt))) (unless (markerp marker) (error "Internal error: loc-changes-alist is not a marker")) (goto-char (marker-position marker))) (if no-update - (loc-changes-goto-line position) - (loc-changes-add-and-goto position)) + (loc-changes-goto-line line-number) + (loc-changes-add-and-goto line-number)) ) ) ) diff --git a/packages/loc-changes/test/Makefile.am b/packages/loc-changes/test/Makefile.am index 48f7f72..2d6a227 100644 --- a/packages/loc-changes/test/Makefile.am +++ b/packages/loc-changes/test/Makefile.am @@ -49,7 +49,7 @@ check: $(CHECK_FILES) #: Run all tests via el-get check-elget: - (cd $(top_srcdir)/test && $(EMACS) --batch --no-site-file --no-splash --load ./install-pkgs.el --load test-basic.el) + (cd $(top_srcdir)/test && $(EMACS) --batch --no-site-file --no-splash --load ../el-get-install.el --load test-basic.el) #: Run all tests with minimum verbosity check-short: diff --git a/packages/loc-changes/test/install-pkgs.el b/packages/loc-changes/test/install-pkgs.el deleted file mode 100644 index d43575c..0000000 --- a/packages/loc-changes/test/install-pkgs.el +++ /dev/null @@ -1,24 +0,0 @@ -;; Copyright (C) 2015 Free Software Foundation, Inc - -;; Author: Rocky Bernstein <ro...@gnu.org> - -;; This program 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 of the License, or -;; (at your option) any later version. - -;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>. - -(require 'package) -(package-refresh-contents) -(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/"))) -(condition-case nil - (package-install 'test-simple) - ((debug error) nil)) -(load-library "test-simple")