From: unknown Date: Wed, 21 Mar 2012 16:54:31 +0000 (+0100) Subject: additional global bindings, goto-last-change, nxml config updates X-Git-Url: http://g0dil.de/git?p=emacs-init.git;a=commitdiff_plain;h=fb90d49978d6f813ec82d1764dca038a116d2afc additional global bindings, goto-last-change, nxml config updates --- diff --git a/auto-install/goto-last-change.el b/auto-install/goto-last-change.el new file mode 100644 index 0000000..b7cd54b --- /dev/null +++ b/auto-install/goto-last-change.el @@ -0,0 +1,141 @@ +;;; goto-last-change.el --- Move point through buffer-undo-list positions -*-unibyte: t; coding: iso-8859-1;-*- + +;; Copyright © 2003 Kevin Rodgers + +;; Author: Kevin Rodgers +;; Created: 17 Jun 2003 +;; Version: $Revision: 1.2 $ +;; Keywords: convenience +;; RCS: $Id: goto-last-change.el,v 1.2 2003/07/30 17:43:47 kevinr Exp kevinr $ + +;; Contributors: +;; Attila Lendvai (line distance and auto marks) + +;; 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 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, write to the Free +;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, +;; MA 02111-1307 USA + +;;; Commentary: + +;; After installing goto-last-change.el in a `load-path' directory and +;; compiling it with `M-x byte-compile-file', load it with +;; (require 'goto-last-change) +;; or autoload it with +;; (autoload 'goto-last-change "goto-last-change" +;; "Set point to the position of the last change." t) +;; +;; You may also want to bind a key to `M-x goto-last-change', e.g. +;; (global-set-key "\C-x\C-\\" 'goto-last-change) + +;; goto-last-change.el was written in response to to the following: +;; +;; From: Dan Jacobson +;; Newsgroups: gnu.emacs.bug +;; Subject: function to go to spot of last change +;; Date: Sun, 15 Jun 2003 00:15:08 +0000 (UTC) +;; Sender: news +;; Message-ID: +;; NNTP-Posting-Host: monty-python.gnu.org +;; +;; +;; Why of course, a function to get the user to the spot of last changes +;; in the current buffer(s?), that's what emacs must lack. +;; +;; How many times have you found yourself mosying [<-not in spell +;; checker!?] thru a file when you wonder, where the heck was I just +;; editing? Well, the best you can do is hit undo, ^F, and undo again, +;; to get back. Hence the "burning need" for the additional function, +;; which you might name the-jacobson-memorial-function, due to its brilliance. +;; -- +;; http://jidanni.org/ Taiwan(04)25854780 + +;;; Code: +(provide 'goto-last-change) + +(or (fboundp 'last) ; Emacs 20 + (require 'cl)) ; Emacs 19 + +(defvar goto-last-change-undo nil + "The `buffer-undo-list' entry of the previous \\[goto-last-change] command.") +(make-variable-buffer-local 'goto-last-change-undo) + +;;;###autoload +(defun goto-last-change (&optional mark-point minimal-line-distance) + "Set point to the position of the last change. +Consecutive calls set point to the position of the previous change. +With a prefix arg (optional arg MARK-POINT non-nil), set mark so \ +\\[exchange-point-and-mark] +will return point to the current position." + (interactive "P") + ;; (unless (buffer-modified-p) + ;; (error "Buffer not modified")) + (when (eq buffer-undo-list t) + (error "No undo information in this buffer")) + (when mark-point + (push-mark)) + (unless minimal-line-distance + (setq minimal-line-distance 10)) + (let ((position nil) + (undo-list (if (and (eq this-command last-command) + goto-last-change-undo) + (cdr (memq goto-last-change-undo buffer-undo-list)) + buffer-undo-list)) + undo) + (while (and undo-list + (or (not position) + (eql position (point)) + (and minimal-line-distance + ;; The first invocation always goes to the last change, subsequent ones skip + ;; changes closer to (point) then minimal-line-distance. + (memq last-command '(goto-last-change + goto-last-change-with-auto-marks)) + (< (count-lines (min position (point-max)) (point)) + minimal-line-distance)))) + (setq undo (car undo-list)) + (cond ((and (consp undo) (integerp (car undo)) (integerp (cdr undo))) + ;; (BEG . END) + (setq position (cdr undo))) + ((and (consp undo) (stringp (car undo))) ; (TEXT . POSITION) + (setq position (abs (cdr undo)))) + ((and (consp undo) (eq (car undo) t))) ; (t HIGH . LOW) + ((and (consp undo) (null (car undo))) + ;; (nil PROPERTY VALUE BEG . END) + (setq position (cdr (last undo)))) + ((and (consp undo) (markerp (car undo)))) ; (MARKER . DISTANCE) + ((integerp undo)) ; POSITION + ((null undo)) ; nil + (t (error "Invalid undo entry: %s" undo))) + (setq undo-list (cdr undo-list))) + (cond (position + (setq goto-last-change-undo undo) + (goto-char (min position (point-max)))) + ((and (eq this-command last-command) + goto-last-change-undo) + (setq goto-last-change-undo nil) + (error "No further undo information")) + (t + (setq goto-last-change-undo nil) + (error "Buffer not modified"))))) + +(defun goto-last-change-with-auto-marks (&optional minimal-line-distance) + "Calls goto-last-change and sets the mark at only the first invocations +in a sequence of invocations." + (interactive "P") + (goto-last-change (not (or (eq last-command 'goto-last-change-with-auto-marks) + (eq last-command t))) + minimal-line-distance)) + +;; (global-set-key "\C-x\C-\\" 'goto-last-change) + +;;; goto-last-change.el ends here diff --git a/emacs-custom.el b/emacs-custom.el index b2e8f39..9044c9c 100644 --- a/emacs-custom.el +++ b/emacs-custom.el @@ -30,7 +30,7 @@ '(global-auto-revert-mode nil) '(global-highlight-changes-mode t) '(global-subword-mode t) - '(global-visual-line-mode t) + '(global-visual-line-mode nil) '(global-whitespace-mode nil) '(highlight-changes-colors nil) '(highlight-changes-face-list nil) @@ -43,6 +43,7 @@ '(ispell-dictionary "deutsch8") '(ispell-extra-args (quote ("--sug-mode=ultra"))) '(ispell-program-name "c:/cygwin/bin/aspell.exe") + '(line-move-visual nil) '(ls-lisp-dirs-first t) '(nxml-child-indent 4) '(nxml-where-global-mode nil) diff --git a/setup/bindings.el b/setup/bindings.el index c06b502..4611b16 100644 --- a/setup/bindings.el +++ b/setup/bindings.el @@ -1 +1,10 @@ (global-set-key "\M-/" 'hippie-expand) +(global-set-key "\C-c'w" 'which-func-mode) +(global-set-key "\C-c'h" 'highlight-changes-mode) +(global-set-key "\C-c'f" 'auto-fill-mode) +(global-set-key "\C-c'v" 'visual-line-mode) +(global-set-key "\C-c'd" 'toggle-debug-on-error) +(global-set-key "\C-c'g" 'toggle-debug-on-quit) +(global-set-key "\C-c'c" 'toggle-case-fold-search) +(global-set-key "\C-c's" 'flyspell-mode) +(global-set-key (kbd "C-+") ' goto-last-change) diff --git a/setup/nxml.el b/setup/nxml.el index 872bd4c..2ee07cf 100644 --- a/setup/nxml.el +++ b/setup/nxml.el @@ -39,6 +39,17 @@ (mapconcat 'identity (nconc path-to-id path-rest) "/")))) (require 'which-func) +(which-func-mode) + +(delete (assoc 'which-func-mode mode-line-format) mode-line-format) +(setq which-func-header-line-format + '(which-func-mode + ("" which-func-format + ))) +(defadvice which-func-ff-hook (after header-line activate) + (when which-func-mode + (delete (assoc 'which-func-mode mode-line-format) mode-line-format) + (setq header-line-format which-func-header-line-format))) (add-to-list 'which-func-functions 'nxml-where) (add-to-list 'which-func-modes 'nxml-mode) @@ -119,10 +130,10 @@ ("orderedlist" . ("listitem")) ("variablelist" . ("varlistentry")) ("varlistentry" . ("term" "listitem")) - ("term" . ("emphasis" "code")) + ("term" . ("emphasis" "code" "replaceable")) ("listitem" . ("para" "itemizedlist")) ("task" . ("tasksummary" "procedure" "title")) - ("tasksummary" . ("para")) + ("tasksummary" . ("para" "itemizedlist" "variablelist")) ("procedure" . ("step")) ("step" . ("para" "procedure")) ("mathphrase" . ("replaceable" "superscript" "subscript")) @@ -198,7 +209,6 @@ finally return 0)))) 0)) (element (and elements (nth index elements)))) - (message "!elements %s %s %s" common-elements valid-elements elements) (when (not elements) (error "No common elements for %s" context)) (if element @@ -232,10 +242,36 @@ (defun nxml-open-line () (interactive) - (open-line 1) - (save-excursion - (forward-line 1) - (indent-according-to-mode)) - (newline-and-indent)) + (if (region-active-p) + (let ((start (region-beginning)) + (end (region-end)) + chars) + (save-excursion + (goto-char end) + (newline-and-indent) + (goto-char start) + (setq chars (- (- (point) (progn (newline-and-indent) (point))))) + (indent-region (+ start chars) (+ end chars)))) + (open-line 1) + (save-excursion + (forward-line 1) + (indent-according-to-mode)) + (newline-and-indent))) + +(defun nxml-split-element () + (interactive) + (let (element block-p) + (save-excursion + (nxml-backward-up-element) + (setq element (xmltok-start-tag-qname) + block-p (looking-back "^\s-*" (save-excursion (beginning-of-line) (point))))) + (delete-horizontal-space) + (insert "") + (fill-paragraph) + (insert "\n") + (newline-and-indent) + (insert "<" element ">") + (fill-paragraph))) (define-key nxml-mode-map (kbd "M-o") 'nxml-open-line) +(define-key nxml-mode-map (kbd "S-") 'nxml-split-element)