1 ;;; elbb-misc-utils.el --- misc-utils for all Emacsen
5 ;; This is free software: you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 2 of the License, or
8 ;; (at your option) any later version.
10 ;; This is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19 ;; Copyright (C) 2009 by Andreas Roehler
20 ;; Author Andreas Roehler <andreas.roehler@online.de>
22 (defun read-buffer-by-top-level-form (&optional beg end
)
23 "Read buffer step by step by top-level-form.
24 Prints position into the message-buffer after evaluation.
25 Stepps through region if activated, otherwise takes the whole buffer."
27 (when (string-match ".gnu-emacs-all-cvs" (buffer-file-name)) (emacs-lisp-mode))
28 (let ((beg (cond (beg beg
)
32 (end (cond (end (copy-marker end
))
34 (copy-marker (region-end)))
35 (t (copy-marker (point-max)))))
42 (while (and (not (eobp))
44 (setq last-pos-line
(count-lines 1 (point)))
45 (message "%s" last-pos-line
)
48 (while (nth 4 (parse-partial-sexp (line-beginning-position) (point)))
51 (message "point %s" (point))
52 (setq this-pos-line
(count-lines 1 (point)))
53 (if (eq 1 (- this-pos-line last-pos-line
))
54 (unless (y-or-n-p "Attention: Single line espressions. Continue?")
55 (throw 'fehler
(ignore)))
57 (eval-last-sexp nil
))))
58 (message "%s" " Finished! Buffer was set `read-only' for security reasons. ")))))
60 ;; (global-set-key [(control kp-9)] 'reverse-chars)
61 (defun reverse-chars ()
62 "Reverse reciproke chars as \"[\" to \"]\", upcase or downcase. "
64 (let* ((cf (char-after))
66 (cond ((or (eq cf
62)(eq cf ?\
>))
68 ((or (eq cf
60)(eq cf ?\
<))
70 ((or (eq cf
40)(eq cf ?\
())
72 ((or (eq cf
41)(eq cf ?\
)))
74 ((or (eq cf
123) (eq cf ?\
{))
76 ((or (eq cf
125) (eq cf ?\
}))
78 ((or (eq cf
93)(eq cf ?\
]))
80 ((or (eq cf
91)(eq cf ?\
[))
82 ((or (eq cf
45)(eq cf ?\-
))
84 ((or (eq cf
95)(eq cf ?\_
))
87 (setq cn
(upcase cf
)))))
91 ;; elbb-misc-utils.el ends here