Add mark package

This commit is contained in:
Gergely Polonkai 2015-05-04 11:49:47 +02:00
parent 24fdfbc70d
commit 4cef57c82e
6 changed files with 564 additions and 0 deletions

View File

@ -0,0 +1,15 @@
;;; fm-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
;;;### (autoloads nil nil ("fm.el") (21831 16363 381489 630000))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; End:
;;; fm-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "fm" "20130612.1" "follow mode for compilation/output buffers" 'nil)

230
elpa/fm-20130612.1/fm.el Normal file
View File

@ -0,0 +1,230 @@
;;; fm.el --- follow mode for compilation/output buffers
;; Copyright (C) 1997 Stephen Eglen
;; Author: Stephen Eglen <stephen@anc.ed.ac.uk>
;; Maintainer: Stephen Eglen <stephen@anc.ed.ac.uk>, Joe Bloggs <vapniks@yahoo.com>
;; Created: 03 Jul 1997
;; Version: 20130612.1
;; Keywords: outlines
;; location: https://github.com/vapniks/fm
;; 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 2, 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 GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; As you move through the lines of an output buffer (such as from
;; `grep' or `occur'), another window highlights the corresponding
;; line of the source buffer.
;; This is inspired by the table of contents code from reftex.el.
;; http://www.strw.leidenuniv.nl/~dominik/Tools/
;; To use the mode, do M-x fm-start in the output buffer. Or just add
;; it to the mode hooks, e.g.:
;; (add-hook 'occur-mode-hook 'fm-start)
;; (add-hook 'compilation-mode-hook 'fm-start)
;;
;;; Examples:
;;
;; Do an occur for the word `package' in the NEWS file:
;; C-h n
;; M-x occur RTN package RTN
;; or test it on the current file:
;; (grep "grep -n 'def' fm.el")
;; (occur "def")
;; Once following is activated in a buffer, it can be toggled with the
;; "f" key in that buffer.
;; To extend this code to handle other types of output buffer, you
;; need to add an entry to the alist `fm-modes', e.g:
;; (add-to-list 'fm-modes '(my-mode my-mode-goto-item))
;; where my-mode-goto-item is a function that opens the source buffer
;; at the place appropriate for the current item.
;; You can set the number of lines to display in the items buffer when
;; in fm-mode by setting the buffer local variable `fm-window-lines'.
;; If you want to use fm in a buffer that doesn't have a useful major
;; mode, you can always set the value of fm-defun yourself. For
;; example, the cscope buffer is in fundamental mode, so in this case
;; we set fm-defun as a local variable to be the defun to use for
;; visiting the corresponding line of the source buffer.
(add-hook 'cscope-query-hook 'cscope-run-fm)
(defun cscope-run-fm ()
"Run cscope in the fm buffer."
(set (make-local-variable 'fm-defun) '(cscope-interpret-output-line))
;; You can set the number of lines to show to 10 by uncommenting the following line.
;; (setq fm-window-lines 10)
(fm-start))
;; If you are using this in the compile mode, you may find it easier
;; to use the key M-p to go to the previous error. Otherwise, you may
;; find that if you go up one line, and this line doesn't have an
;; error on it, it goes down one line again, taking you back where you
;; started!
;;; Installation:
;;
;; Put fm.el in a directory in your load-path, e.g. ~/.emacs.d/
;; You can add a directory to your load-path with the following line in ~/.emacs
;; (add-to-list 'load-path (expand-file-name "~/elisp"))
;; where ~/elisp is the directory you want to add
;; (you don't need to do this for ~/.emacs.d - it's added by default).
;;
;; Add the following to your ~/.emacs startup file.
;;
;; (require 'fm)
;;; TODO
;; ??
;;; Code:
;; fm-highlight is currently used to highlight the regions of both
;; the source(0) and output(1) buffers.
(defvar fm-modes
'( (compilation-mode compile-goto-error)
(occur-mode occur-mode-goto-occurrence)
(outlines-mode outlines-goto-line) ;; sje hack
;;(fundamental-mode cscope-interpret-output-line) ;;todo big time
)
"Alist of modes and the corresponding defun to visit source buffer.")
;; toggles...
(defvar fm-working t)
(defvar fm-window-lines nil
"If non-nil then set the output buffer to this many lines in height when follow mode is on.")
(make-variable-buffer-local 'fm-window-lines)
(defun fm-start ()
"Set up `follow-mode' to run on the current buffer.
This should be added to buffers through hooks, such as
`occur-mode-hook'."
(interactive)
(let ((l))
;; first check to see if it is worth running fm in this mode.
(if (not (boundp 'fm-defun))
(progn
(setq f (cdr (assoc major-mode fm-modes)))
(if f
(set (make-local-variable 'fm-defun) f))))
(if (boundp 'fm-defun)
(progn
(add-hook 'post-command-hook 'fm-post-command-hook nil 'local)
(add-hook 'pre-command-hook 'fm-pre-command-hook nil 'local)
(local-set-key "f" 'fm-toggle)
)
;; else
(error "Cannot use fm in this mode."))))
(defun fm-pre-command-hook ()
"Remove highlighing in both source and output buffers."
;; used as pre command hook in *toc* buffer
(if fm-working
(progn
(fm-unhighlight 0)
(fm-unhighlight 1)
)))
(defun fm-post-command-hook (&optional lines)
"Add the highlighting if possible to both source and output buffers."
;;(message (format "run post in %s" (buffer-name)) )
(if fm-working
(let (ret)
(progn
(let ((buf (buffer-name))
(f nil))
;; select current line.
(if (not (boundp 'fm-defun))
(error "Cannot use fm in this buffer."))
(setq ret
(condition-case nil
(eval fm-defun)
(error 'failed)))
;;(message "ret is %s" ret)
(if (not (eq ret 'failed))
(progn
;; make the highlight in the source buffer.
(save-excursion
(fm-highlight 0
(progn (beginning-of-line) (point))
(progn (end-of-line) (point))))
;; make the highlight in the output buffer.
(pop-to-buffer buf)
(and (> (point) 1)
(save-excursion
(fm-highlight 1
(progn (beginning-of-line) (point))
(progn (end-of-line) (point)))))
(if fm-window-lines
(shrink-window (- (window-body-height) fm-window-lines))))
;; else there was an error
(progn
;; make sure we stay in output buffer.
(pop-to-buffer buf)
(message "couldn't find line..."))))))))
(defun fm-toggle ()
"Toggle the fm behaviour on and off."
(interactive)
(setq fm-working (not fm-working)))
;;; Highlighting (copied from reftex.el -- cheers Carsten!)
;; Highlighting uses overlays. If this is for XEmacs, we need to load
;; the overlay library, available in version 19.15
(and (not (fboundp 'make-overlay))
(condition-case nil
(require 'overlay)
('error
(error "Fm needs overlay emulation (available in XEmacs 19.15)"))))
;; We keep a vector with several different overlays to do our highlighting.
(defvar fm-highlight-overlays [nil nil])
;; Initialize the overlays
(aset fm-highlight-overlays 0 (make-overlay 1 1))
(overlay-put (aref fm-highlight-overlays 0) 'face 'highlight)
(aset fm-highlight-overlays 1 (make-overlay 1 1))
(overlay-put (aref fm-highlight-overlays 1) 'face 'highlight)
;; Two functions for activating and deactivation highlight overlays
(defun fm-highlight (index begin end &optional buffer)
"Highlight a region with overlay INDEX."
(move-overlay (aref fm-highlight-overlays index)
begin end (or buffer (current-buffer))))
(defun fm-unhighlight (index)
"Detatch overlay INDEX."
(delete-overlay (aref fm-highlight-overlays index)))
(provide 'fm)
;;; fm.el ends here

View File

@ -0,0 +1,53 @@
;;; mark-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (or (file-name-directory #$) (car load-path)))
;;;### (autoloads nil "mark" "mark.el" (21831 16364 152207 38000))
;;; Generated autoloads from mark.el
(autoload 'backward-mark "mark" "\
Moves the point arg points backward in the mark ring.
\(fn ARG)" t nil)
(autoload 'forward-mark "mark" "\
Moves the point arg points forward in the mark ring.
\(fn ARG)" t nil)
(autoload 'mark-mode-goto "mark" "\
Go to the occurrence the current line describes.
\(fn)" t nil)
(autoload 'mark-mode-delete "mark" "\
Delete mark at current line from mark-ring.
\(fn)" t nil)
(autoload 'mark-mode-prev-mark "mark" "\
Move to previous mark in *mark* buffer, wrapping if necessary.
\(fn)" t nil)
(autoload 'mark-mode-next-mark "mark" "\
Move to next mark in *mark* buffer, wrapping if necessary.
\(fn)" t nil)
(autoload 'show-marks "mark" "\
Displays all the lines for each point in the mark ring. Pressing
RET in the result buffer will send you to corresponding mark point
with out affecting the mark-ring.
\(fn)" t nil)
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; End:
;;; mark-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "mark" "0.3" "Navigate and visualize the mark-ring" '((fm "1.0")))

264
elpa/mark-0.3/mark.el Normal file
View File

@ -0,0 +1,264 @@
;;; mark.el --- Navigate and visualize the mark-ring
;; Filename: mark.el
;; Description: Navigate and visualize the mark-ring
;; Author: Greg Rowe <emacs@therowes.net>
;; Maintainer: Joe Bloggs <vapniks@yahoo.com>
;; Copyright (c) 2003 Greg Rowe
;; Created: 2003
;; Version: 0.3
;; Last-Updated: 2013-05-20 23:37:35
;; By: Joe Bloggs
;; URL: https://github.com/vapniks/mark
;; Keywords: convenience
;; Compatibility: GNU Emacs 24.3.1
;; Package-Requires: ((fm "1.0"))
;;
;; Features that might be required by this library:
;;
;; fm
;;
;;; This file is NOT part of GNU Emacs
;;; License
;;
;; 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, 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; see the file COPYING.
;; If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; * Commentary
;; This library provides the commands to navigate and display the mark ring.
;; The `show-marks' command displays a buffer listing the marks in the buffer from which it was called.
;; You can then press enter on one of the listed marks to jump to it, or press d to delete it from the
;; mark ring. You can also use the `forward-mark' and `backward-mark' commands to navigate the marks in
;; the mark ring.
;;; Installation:
;;
;; Put mark.el in a directory in your load-path, e.g. ~/.emacs.d/
;; You can add a directory to your load-path with the following line in ~/.emacs
;; (add-to-list 'load-path (expand-file-name "~/elisp"))
;; where ~/elisp is the directory you want to add
;; (you don't need to do this for ~/.emacs.d - it's added by default).
;;
;; Add the following to your ~/.emacs startup file.
;;
;; (require 'mark)
;;
;; I recommend also binding the commands to global keys, e.g:
;;
;; (global-set-key (kbd "<C-s-right>") 'forward-mark)
;; (global-set-key (kbd "<C-s-left>") 'backward-mark)
;; (global-set-key (kbd "<C-s-down>") 'show-marks)
;;
;;;;
;;; Customize:
;;
;;
;;
;; All of the above can customized by:
;; M-x customize-group RET mark RET
;;
;;; Change log:
;;
;; 2013/05/10 - Joe Bloggs
;; * Added to github
;; 2010/02/17 - Joe Bloggs
;; * Use fm with mark-mode
;; * New commands: mark-mode-delete mark-mode-prev-mark mark-mode-next-mark
;; * New keybindings for mark-mode
;;
;;; Acknowledgements:
;;
;; Original author: Greg Rowe
;;
;;; TODO
;;
;;
;;
;;; Require
(require 'fm)
;;; Code:
(defvar mark-ring-pos -1
"This tracks the current position in the mark ring for movement.")
(make-variable-buffer-local 'mark-ring-pos)
;; Advise `set-mark-command'
(defadvice set-mark-command (after mark-reset-pos (arg))
"After set-mark-command is called the mark-ring position will be
reset."
(setq mark-ring-pos -1))
(ad-activate 'set-mark-command)
;; use addition to go backwards, and subtraction to go forward
;;;###autoload
(defun backward-mark (arg)
"Moves the point arg points backward in the mark ring."
(interactive "P")
(if (null arg) (setq arg 1))
(if (or mark-ring (mark t))
(progn
(let ((mark-ring-length (length mark-ring)))
(setq mark-ring-pos (+ mark-ring-pos (abs arg)))
(if (> mark-ring-pos mark-ring-length)
(setq mark-ring-pos
(- (- mark-ring-pos mark-ring-length ) 1)))
(goto-nth-mark mark-ring-pos)))))
;;;###autoload
(defun forward-mark (arg)
"Moves the point arg points forward in the mark ring."
(interactive "P")
(if (= -1 mark-ring-pos) (setq mark-ring-pos 0))
(if (null arg) (setq arg 1))
(if (or mark-ring (mark t))
(progn
(let ((mark-ring-length (length mark-ring)))
(setq mark-ring-pos (- mark-ring-pos (abs arg)))
(if (< mark-ring-pos 0)
(setq mark-ring-pos
(+ (+ mark-ring-length mark-ring-pos) 1)))
(goto-nth-mark mark-ring-pos)))))
(defun goto-nth-mark (arg)
;; Moves the point to the nth position in the mark ring (starts at 1).
(let ((the-place (cond
((= arg 0) (mark t))
((= arg 1) (car mark-ring))
(t (car (nthcdr (- arg 1) mark-ring))))))
(if the-place
(goto-char the-place))))
(defvar mark-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-m" 'mark-mode-goto)
(define-key map (kbd "<delete>") 'mark-mode-delete)
(define-key map "d" 'mark-mode-delete)
(define-key map "q" 'delete-window)
(define-key map (kbd "<up>") 'mark-mode-prev-mark)
(define-key map (kbd "<down>") 'mark-mode-next-mark)
(define-key map "x" (lambda nil (interactive) (kill-buffer (current-buffer))))
map)
"Keymap for `mark-mode'.")
(defvar mark-buffer nil
"Name of buffer for last show-marks.")
(put 'mark-mode 'mode-class 'special)
(define-derived-mode mark-mode nil "mark"
"Major mode for output from \\[show-marks].
\\<mark-mode-map>Move point to one of the items in this buffer, then use
\\[mark-mode-goto] to go to the mark that the item refers to.
\\{mark-mode-map}"
(make-local-variable 'mark-buffer)
(add-to-list 'fm-modes '(mark-mode mark-mode-goto))
(toggle-read-only 1)
(fm-start))
;;;###autoload
(defun mark-mode-goto ()
"Go to the occurrence the current line describes."
(interactive)
(let ((pos (get-text-property (point) 'marker)))
(pop-to-buffer mark-buffer)
(goto-char pos)))
;;;###autoload
(defun mark-mode-delete nil
"Delete mark at current line from mark-ring."
(interactive)
(let ((mark (get-text-property (point) 'marker)))
(with-current-buffer mark-buffer
(setq mark-ring (delete mark mark-ring)))
(toggle-read-only -1)
(kill-line 1)
(toggle-read-only 1)))
;;;###autoload
(defun mark-mode-prev-mark ()
"Move to previous mark in *mark* buffer, wrapping if necessary."
(interactive)
(if (> (line-number-at-pos) 1)
(previous-line)
(goto-char (point-max))
(previous-line)
(move-beginning-of-line nil)))
;;;###autoload
(defun mark-mode-next-mark ()
"Move to next mark in *mark* buffer, wrapping if necessary."
(interactive)
(if (< (line-number-at-pos) (count-lines (point-min) (point-max)))
(next-line)
(goto-char (point-min))
(move-beginning-of-line nil)))
(defun show-mark (mark-list)
(if mark-list
(let ((mymarker (car mark-list))
(linenum 0)
(mybol 0)
(myeol 0)
(prop-start 0))
(save-current-buffer
(set-buffer mark-buffer)
(setq linenum (+ (count-lines 1 mymarker) 1))
(save-excursion
(goto-char mymarker)
(setq mybol (point-at-bol))
(setq myeol (point-at-eol))))
(setq prop-start (point))
(insert (format "%6d: " linenum))
(insert-buffer-substring mark-buffer mybol myeol)
(insert "\n")
(put-text-property prop-start (point) 'marker mymarker)
(show-mark (cdr mark-list)))))
;;;###autoload
(defun show-marks ()
"Displays all the lines for each point in the mark ring. Pressing
RET in the result buffer will send you to corresponding mark point
with out affecting the mark-ring."
(interactive)
(with-output-to-temp-buffer "*marks*"
(let ((old-buffer-mark-ring mark-ring))
;; prepend the current mark
(setq old-buffer-mark-ring (cons (copy-marker (mark-marker)) mark-ring))
(setq mark-buffer (current-buffer))
(set-buffer standard-output)
(show-mark old-buffer-mark-ring)
(mark-mode))))
(provide 'mark)
;; (magit-push)
;; (yaoddmuse-post "EmacsWiki" "mark.el" (buffer-name) (buffer-string) "update")
;;; mark.el ends here