* pces.el: Require `pces-raw' if file-coding feature is not
[elisp/apel.git] / inv-18.el
1 ;;; inv-18.el --- invisible feature implementation for Emacs 18
2
3 ;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: invisible, text-property, region, Emacs 18
7
8 ;; This file is part of APEL (A Portable Emacs Library).
9
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
14
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (defmacro enable-invisible ()
28   (`
29    (progn
30      (make-local-variable 'original-selective-display)
31      (setq original-selective-display selective-display)
32      (setq selective-display t)
33      )))
34
35 (defmacro end-of-invisible ()
36   (` (setq selective-display
37            (if (boundp 'original-selective-display)
38                original-selective-display))
39      ))
40
41 (defun invisible-region (start end)
42   (let ((buffer-read-only nil)          ;Okay even if write protected.
43         (modp (buffer-modified-p)))
44     (if (save-excursion
45           (goto-char (1- end))
46           (eq (following-char) ?\n)
47           )
48         (setq end (1- end))
49       )
50     (unwind-protect
51         (subst-char-in-region start end ?\n ?\^M t)
52       (set-buffer-modified-p modp)
53       )))
54
55 (defun visible-region (start end)
56   (let ((buffer-read-only nil)          ;Okay even if write protected.
57         (modp (buffer-modified-p)))
58     (unwind-protect
59         (subst-char-in-region start end ?\^M ?\n t)
60       (set-buffer-modified-p modp)
61       )))
62
63 (defun invisible-p (pos)
64   (save-excursion
65     (goto-char pos)
66     (eq (following-char) ?\^M)
67     ))
68
69 (defun next-visible-point (pos)
70   (save-excursion
71     (goto-char pos)
72     (end-of-line)
73     (if (eq (following-char) ?\n)
74         (forward-char)
75       )
76     (point)
77     ))
78
79
80 ;;; @ end
81 ;;;
82
83 (provide 'inv-18)
84
85 ;;; inv-18.el ends here