-;;; loc-changes.el --- Helps users and programs keep track of positions even after buffer changes.
+;;; loc-changes.el --- keep track of positions even after buffer changes
-;; Author: Rocky Bernstein
-;; Version: 1.1
+;; Copyright (C) 2015 Free Software Foundation, Inc
+
+;; Author: Rocky Bernstein <rocky@gnu.org>
+;; Version: 1.2
;; URL: http://github.com/rocky/emacs-loc-changes
;; Compatibility: GNU Emacs 24.x
-;; Copyright (C) 2013-2014 Rocky Bernstein <rocky@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 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.
+;; 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/>.
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; Another use might be in a compilation buffer for errors and
;; warnings which refer to file and line positions.
-;; Should be available via Melpa.
-
-
;;; Code:
(make-variable-buffer-local 'loc-changes-alist)
the marker"
)
+(defun loc-changes:follow-mark(event)
+ (interactive "e")
+ (let* ((pos (posn-point (event-end event)))
+ (mark (get-text-property pos 'mark)))
+ (switch-to-buffer-other-window (marker-buffer mark))
+ (goto-char (marker-position mark))
+ ))
+
+
+(defun loc-changes:alist-describe (&optional opt-buffer)
+ "Display buffer-local variable loc-changes-alist. If BUFFER is
+not given, the current buffer is used. Information is put in an
+internal buffer called *Describe*."
+ (interactive "")
+ (let ((buffer (or opt-buffer (current-buffer)))
+ (alist))
+ (with-current-buffer buffer
+ (setq alist loc-changes-alist)
+ (unless (listp alist) (error "expecting loc-changes-alist to be a list"))
+ )
+ (switch-to-buffer (get-buffer-create "*Describe*"))
+ (setq buffer-read-only 'nil)
+ (delete-region (point-min) (point-max))
+ (dolist (assoc alist)
+ (put-text-property
+ (insert-text-button
+ (format "line %d: %s\n" (car assoc) (cdr assoc))
+ 'action 'loc-changes:follow-mark
+ 'help-echo "mouse-2: go to this location")
+ (point)
+ 'mark (cdr 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
)
(provide 'loc-changes)
-
;;; loc-changes.el ends here