Revert "peel-list"
[elbb.git] / code / elbb-misc-utils.el
blobfaaf98b92f94c1eaf611424f43bd8faf5898aa0b
1 ;;; elbb-misc-utils.el --- misc-utils for all Emacsen
3 ;; Keywords: lisp
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."
26 (interactive)
27 (when (string-match ".gnu-emacs-all-cvs" (buffer-file-name)) (emacs-lisp-mode))
28 (let ((beg (cond (beg beg)
29 ((region-active-p)
30 (region-beginning))
31 (t (point-min))))
32 (end (cond (end (copy-marker end))
33 ((region-active-p)
34 (copy-marker (region-end)))
35 (t (copy-marker (point-max)))))
36 (last-pos-line 1)
37 this-pos-line)
38 (save-excursion
39 (toggle-read-only 1)
40 (catch 'fehler
41 (goto-char beg)
42 (while (and (not (eobp))
43 (< (point) end))
44 (setq last-pos-line (count-lines 1 (point)))
45 (message "%s" last-pos-line)
46 (forward-sexp 1)
47 ;; in comment
48 (while (nth 4 (parse-partial-sexp (line-beginning-position) (point)))
49 (forward-line 1)
50 (end-of-line))
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)))
56 (save-excursion
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. "
63 (interactive "*")
64 (let* ((cf (char-after))
65 (cn (downcase cf)))
66 (cond ((or (eq cf 62)(eq cf ?\>))
67 (setq cn "<"))
68 ((or (eq cf 60)(eq cf ?\<))
69 (setq cn ">"))
70 ((or (eq cf 40)(eq cf ?\())
71 (setq cn ")"))
72 ((or (eq cf 41)(eq cf ?\)))
73 (setq cn "("))
74 ((or (eq cf 123) (eq cf ?\{))
75 (setq cn "}"))
76 ((or (eq cf 125) (eq cf ?\}))
77 (setq cn "{"))
78 ((or (eq cf 93)(eq cf ?\]))
79 (setq cn "["))
80 ((or (eq cf 91)(eq cf ?\[))
81 (setq cn "]"))
82 ((or (eq cf 45)(eq cf ?\-))
83 (setq cn "_"))
84 ((or (eq cf 95)(eq cf ?\_))
85 (setq cn "-"))
86 (t (when (eq cf cn)
87 (setq cn (upcase cf)))))
88 (delete-char 1)
89 (insert cn)))
91 ;; elbb-misc-utils.el ends here