X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/11b82017b758f099f530d3351d37145d87a339a9..abd8d2a4939d124a8263f9cdbc5d20317fdd2fb3:/packages/loc-changes/loc-changes.el diff --git a/packages/loc-changes/loc-changes.el b/packages/loc-changes/loc-changes.el index 417f2fe78..a269c0a46 100644 --- a/packages/loc-changes/loc-changes.el +++ b/packages/loc-changes/loc-changes.el @@ -1,25 +1,24 @@ -;;; 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 +;; Version: 1.2 ;; URL: http://github.com/rocky/emacs-loc-changes ;; Compatibility: GNU Emacs 24.x -;; Copyright (C) 2013-2014 Rocky Bernstein - -;; 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 -;; . +;; along with this program. If not, see . ;;; Commentary: @@ -34,9 +33,6 @@ ;; 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) @@ -46,6 +42,42 @@ their corresponding markers in the buffer. The 'key' is the line number; the val 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 @@ -222,5 +254,4 @@ NO-UPDATE is set, no mark is added." ) (provide 'loc-changes) - ;;; loc-changes.el ends here