]> code.delx.au - gnu-emacs-elpa/blob - packages/auto-overlays/auto-overlays-compat.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / auto-overlays / auto-overlays-compat.el
1 ;;; auto-overlays-compat.el --- compatability functions for auto-overlays package
2
3
4 ;; Copyright (C) 2005-2015 Free Software Foundation, Inc
5
6 ;; Author: Toby Cubitt <toby-predictive@dr-qubit.org>
7 ;; Version: 0.3.2
8 ;; Keywords: auto-overlay, automatic, overlays, compatability
9 ;; URL: http://www.dr-qubit.org/emacs.php
10
11 ;; This file is NOT part of the Emacs.
12 ;;
13 ;; This file is free software: you can redistribute it and/or modify it under
14 ;; the terms of the GNU General Public License as published by the Free
15 ;; Software Foundation, either version 3 of the License, or (at your option)
16 ;; any later version.
17 ;;
18 ;; This program is distributed in the hope that it will be useful, but WITHOUT
19 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 ;; more details.
22 ;;
23 ;; You should have received a copy of the GNU General Public License along
24 ;; with this program. If not, see <http://www.gnu.org/licenses/>.
25
26
27 ;;; Code:
28
29 (provide 'auto-overlays-compat)
30
31
32 (defun auto-overlays-compat-line-number-at-pos (&optional pos)
33 "Return (narrowed) buffer line number at position POS.
34 \(Defaults to the point.\)"
35 (unless pos (setq pos (point)))
36 ;; note: need to add 1 if at beginning of line
37 (+ (count-lines (point-min) pos)
38 (if (save-excursion (goto-char pos) (bolp)) 1 0))
39 )
40
41
42 (defun auto-overlays-compat-replace-regexp-in-string (regexp rep string)
43 "Return a new string with all matches for REGEXP in STRING replaced
44 with REP."
45 (let ((str string))
46 (while (string-match regexp str)
47 (setq str (replace-match rep nil nil str)))
48 str)
49 )
50
51 ;;; auto-overlays-compat.el ends here