comparison lisp/progmodes/cperl-mode.el @ 111433:05dc9dca8729

Replace end-of-line, save-excursion etc with point-at-eol, point-at-bol. * lisp/mh-e/mh-seq.el (mh-read-msg-list): Use point-at-eol. * lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-show-infos) (gnus-bookmark-kill-line): Use point-at-eol. * lisp/cedet/ede/proj-elisp.el (ede-proj-flush-autoconf): Use point-at-bol. * lisp/emacs-lisp/chart.el (chart-zap-chars): * lisp/play/decipher.el (decipher-set-map): * lisp/progmodes/ada-mode.el (ada-get-current-indent) (ada-search-ignore-string-comment, ada-tab-hard, ada-untab-hard): * lisp/progmodes/ada-prj.el (ada-prj-load-from-file, ada-prj-display-help): * lisp/progmodes/ada-xref.el (ada-initialize-runtime-library) (ada-get-all-references): * lisp/progmodes/cperl-mode.el (cperl-electric-paren) (cperl-electric-rparen, cperl-electric-keyword, cperl-electric-else) (cperl-linefeed, cperl-sniff-for-indent, cperl-to-comment-or-eol) (cperl-find-pods-heres, cperl-indent-exp, cperl-fix-line-spacing) (cperl-word-at-point-hard): * lisp/progmodes/idlw-shell.el (idlwave-shell-move-or-history) (idlwave-shell-filename-string, idlwave-shell-batch-command) (idlwave-shell-display-line): * lisp/progmodes/idlwave.el (idlwave-show-begin, idlwave-fill-paragraph) (idlwave-calc-hanging-indent, idlwave-auto-fill, idlwave-template): * lisp/progmodes/js.el (js--re-search-forward-inner) (js--re-search-backward-inner): * lisp/progmodes/vhdl-mode.el (vhdl-align-region-1, vhdl-align-region-2) (vhdl-fix-clause, vhdl-compose-configuration-architecture): * lisp/progmodes/ruby-mode.el (ruby-parse-partial, eval-when-compile): * lisp/textmodes/flyspell.el (flyspell-process-localwords): * lisp/textmodes/ispell.el (ispell-buffer-local-parsing) (ispell-buffer-local-dict, ispell-buffer-local-words): Use point-at-bol and point-at-eol.
author Glenn Morris <rgm@gnu.org>
date Sat, 06 Nov 2010 18:36:33 -0700
parents d90a3bc6b730
children 56b71cddc9c5
comparison
equal deleted inserted replaced
111432:8de1e4554e5e 111433:05dc9dca8729
1 ;;; cperl-mode.el --- Perl code editing commands for Emacs 1 ;;; cperl-mode.el --- Perl code editing commands for Emacs
2 2
3 ;; Copyright (C) 1985, 1986, 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 3 ;; Copyright (C) 1985, 1986, 1987, 1991, 1992, 1993, 1994, 1995, 1996,
4 ;; 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 4 ;; 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
5 ;; 2010 Free Software Foundation, Inc. 5 ;; 2008, 2009, 2010 Free Software Foundation, Inc.
6 6
7 ;; Author: Ilya Zakharevich 7 ;; Author: Ilya Zakharevich
8 ;; Bob Olson 8 ;; Bob Olson
9 ;; Maintainer: Ilya Zakharevich <ilyaz@cpan.org> 9 ;; Maintainer: Ilya Zakharevich <ilyaz@cpan.org>
10 ;; Keywords: languages, Perl 10 ;; Keywords: languages, Perl
2143 2143
2144 (defun cperl-electric-paren (arg) 2144 (defun cperl-electric-paren (arg)
2145 "Insert an opening parenthesis or a matching pair of parentheses. 2145 "Insert an opening parenthesis or a matching pair of parentheses.
2146 See `cperl-electric-parens'." 2146 See `cperl-electric-parens'."
2147 (interactive "P") 2147 (interactive "P")
2148 (let ((beg (save-excursion (beginning-of-line) (point))) 2148 (let ((beg (point-at-bol))
2149 (other-end (if (and cperl-electric-parens-mark 2149 (other-end (if (and cperl-electric-parens-mark
2150 (cperl-mark-active) 2150 (cperl-mark-active)
2151 (> (mark) (point))) 2151 (> (mark) (point)))
2152 (save-excursion 2152 (save-excursion
2153 (goto-char (mark)) 2153 (goto-char (mark))
2180 (defun cperl-electric-rparen (arg) 2180 (defun cperl-electric-rparen (arg)
2181 "Insert a matching pair of parentheses if marking is active. 2181 "Insert a matching pair of parentheses if marking is active.
2182 If not, or if we are not at the end of marking range, would self-insert. 2182 If not, or if we are not at the end of marking range, would self-insert.
2183 Affected by `cperl-electric-parens'." 2183 Affected by `cperl-electric-parens'."
2184 (interactive "P") 2184 (interactive "P")
2185 (let ((beg (save-excursion (beginning-of-line) (point))) 2185 (let ((beg (point-at-bol))
2186 (other-end (if (and cperl-electric-parens-mark 2186 (other-end (if (and cperl-electric-parens-mark
2187 (cperl-val 'cperl-electric-parens) 2187 (cperl-val 'cperl-electric-parens)
2188 (memq last-command-event 2188 (memq last-command-event
2189 (append cperl-electric-parens-string nil)) 2189 (append cperl-electric-parens-string nil))
2190 (cperl-mark-active) 2190 (cperl-mark-active)
2213 2213
2214 (defun cperl-electric-keyword () 2214 (defun cperl-electric-keyword ()
2215 "Insert a construction appropriate after a keyword. 2215 "Insert a construction appropriate after a keyword.
2216 Help message may be switched off by setting `cperl-message-electric-keyword' 2216 Help message may be switched off by setting `cperl-message-electric-keyword'
2217 to nil." 2217 to nil."
2218 (let ((beg (save-excursion (beginning-of-line) (point))) 2218 (let ((beg (point-at-bol))
2219 (dollar (and (eq last-command-event ?$) 2219 (dollar (and (eq last-command-event ?$)
2220 (eq this-command 'self-insert-command))) 2220 (eq this-command 'self-insert-command)))
2221 (delete (and (memq last-command-event '(?\s ?\n ?\t ?\f)) 2221 (delete (and (memq last-command-event '(?\s ?\n ?\t ?\f))
2222 (memq this-command '(self-insert-command newline)))) 2222 (memq this-command '(self-insert-command newline))))
2223 my do) 2223 my do)
2356 2356
2357 (defun cperl-electric-else () 2357 (defun cperl-electric-else ()
2358 "Insert a construction appropriate after a keyword. 2358 "Insert a construction appropriate after a keyword.
2359 Help message may be switched off by setting `cperl-message-electric-keyword' 2359 Help message may be switched off by setting `cperl-message-electric-keyword'
2360 to nil." 2360 to nil."
2361 (let ((beg (save-excursion (beginning-of-line) (point)))) 2361 (let ((beg (point-at-bol)))
2362 (and (save-excursion 2362 (and (save-excursion
2363 (backward-sexp 1) 2363 (backward-sexp 1)
2364 (cperl-after-expr-p nil "{;:")) 2364 (cperl-after-expr-p nil "{;:"))
2365 (save-excursion 2365 (save-excursion
2366 (not 2366 (not
2395 2395
2396 (defun cperl-linefeed () 2396 (defun cperl-linefeed ()
2397 "Go to end of line, open a new line and indent appropriately. 2397 "Go to end of line, open a new line and indent appropriately.
2398 If in POD, insert appropriate lines." 2398 If in POD, insert appropriate lines."
2399 (interactive) 2399 (interactive)
2400 (let ((beg (save-excursion (beginning-of-line) (point))) 2400 (let ((beg (point-at-bol))
2401 (end (save-excursion (end-of-line) (point))) 2401 (end (point-at-eol))
2402 (pos (point)) start over cut res) 2402 (pos (point)) start over cut res)
2403 (if (and ; Check if we need to split: 2403 (if (and ; Check if we need to split:
2404 ; i.e., on a boundary and inside "{...}" 2404 ; i.e., on a boundary and inside "{...}"
2405 (save-excursion (cperl-to-comment-or-eol) 2405 (save-excursion (cperl-to-comment-or-eol)
2406 (>= (point) pos)) ; Not in a comment 2406 (>= (point) pos)) ; Not in a comment
2474 (if (and over 2474 (if (and over
2475 (progn 2475 (progn
2476 (forward-paragraph -1) 2476 (forward-paragraph -1)
2477 (forward-word 1) 2477 (forward-word 1)
2478 (setq pos (point)) 2478 (setq pos (point))
2479 (setq cut (buffer-substring (point) 2479 (setq cut (buffer-substring (point) (point-at-eol)))
2480 (save-excursion 2480 (delete-char (- (point-at-eol) (point)))
2481 (end-of-line)
2482 (point))))
2483 (delete-char (- (save-excursion (end-of-line) (point))
2484 (point)))
2485 (setq res (expand-abbrev)) 2481 (setq res (expand-abbrev))
2486 (save-excursion 2482 (save-excursion
2487 (goto-char pos) 2483 (goto-char pos)
2488 (insert cut)) 2484 (insert cut))
2489 res)) 2485 res))
2944 (goto-char 2940 (goto-char
2945 (or (next-single-property-change (point) 'in-pod) 2941 (or (next-single-property-change (point) 'in-pod)
2946 (point-max)))) ; do not loop if no syntaxification 2942 (point-max)))) ; do not loop if no syntaxification
2947 ;; label: 2943 ;; label:
2948 (t 2944 (t
2949 (save-excursion (end-of-line) 2945 (setq colon-line-end (point-at-eol))
2950 (setq colon-line-end (point)))
2951 (search-forward ":")))) 2946 (search-forward ":"))))
2952 ;; We are at beginning of code (NOT label or comment) 2947 ;; We are at beginning of code (NOT label or comment)
2953 ;; First, the following code counts 2948 ;; First, the following code counts
2954 ;; if it is before the line we want to indent. 2949 ;; if it is before the line we want to indent.
2955 (and (< (point) indent-point) 2950 (and (< (point) indent-point)
3218 (defun cperl-to-comment-or-eol () 3213 (defun cperl-to-comment-or-eol ()
3219 "Go to position before comment on the current line, or to end of line. 3214 "Go to position before comment on the current line, or to end of line.
3220 Returns true if comment is found. In POD will not move the point." 3215 Returns true if comment is found. In POD will not move the point."
3221 ;; If the line is inside other syntax groups (qq-style strings, HERE-docs) 3216 ;; If the line is inside other syntax groups (qq-style strings, HERE-docs)
3222 ;; then looks for literal # or end-of-line. 3217 ;; then looks for literal # or end-of-line.
3223 (let (state stop-in cpoint (lim (progn (end-of-line) (point))) pr e) 3218 (let (state stop-in cpoint (lim (point-at-eol)) pr e)
3224 (or cperl-font-locking 3219 (or cperl-font-locking
3225 (cperl-update-syntaxification lim lim)) 3220 (cperl-update-syntaxification lim lim))
3226 (beginning-of-line) 3221 (beginning-of-line)
3227 (if (setq pr (get-text-property (point) 'syntax-type)) 3222 (if (setq pr (get-text-property (point) 'syntax-type))
3228 (setq e (next-single-property-change (point) 'syntax-type nil (point-max)))) 3223 (setq e (next-single-property-change (point) 'syntax-type nil (point-max))))
3812 (and (eq system-type 'emx) 3807 (and (eq system-type 'emx)
3813 (eq (point) 1) 3808 (eq (point) 1)
3814 (let ((case-fold-search t)) 3809 (let ((case-fold-search t))
3815 (looking-at "extproc[ \t]")) ; Analogue of #! 3810 (looking-at "extproc[ \t]")) ; Analogue of #!
3816 (cperl-commentify min 3811 (cperl-commentify min
3817 (save-excursion (end-of-line) (point)) 3812 (point-at-eol)
3818 nil)) 3813 nil))
3819 (while (and 3814 (while (and
3820 (< (point) max) 3815 (< (point) max)
3821 (re-search-forward search max t)) 3816 (re-search-forward search max t))
3822 (setq tmpend nil) ; Valid for most cases 3817 (setq tmpend nil) ; Valid for most cases
5000 4995
5001 If `cperl-indent-region-fix-constructs', will improve spacing on 4996 If `cperl-indent-region-fix-constructs', will improve spacing on
5002 conditional/loop constructs." 4997 conditional/loop constructs."
5003 (interactive) 4998 (interactive)
5004 (save-excursion 4999 (save-excursion
5005 (let ((tmp-end (progn (end-of-line) (point))) top done) 5000 (let ((tmp-end (point-at-eol)) top done)
5006 (save-excursion 5001 (save-excursion
5007 (beginning-of-line) 5002 (beginning-of-line)
5008 (while (null done) 5003 (while (null done)
5009 (setq top (point)) 5004 (setq top (point))
5010 ;; Plan A: if line has an unfinished paren-group, go to end-of-group 5005 ;; Plan A: if line has an unfinished paren-group, go to end-of-group
5043 (if (looking-at ; Try Plan C: continuation block 5038 (if (looking-at ; Try Plan C: continuation block
5044 (concat cperl-maybe-white-and-comment-rex 5039 (concat cperl-maybe-white-and-comment-rex
5045 "\\<\\(else\\|elsif\|continue\\)\\>")) 5040 "\\<\\(else\\|elsif\|continue\\)\\>"))
5046 (progn 5041 (progn
5047 (goto-char (match-end 0)) 5042 (goto-char (match-end 0))
5048 (save-excursion 5043 (setq tmp-end (point-at-eol)))
5049 (end-of-line)
5050 (setq tmp-end (point))))
5051 (setq done t)))) 5044 (setq done t))))
5052 (save-excursion 5045 (setq tmp-end (point-at-eol)))
5053 (end-of-line)
5054 (setq tmp-end (point))))
5055 (goto-char tmp-end) 5046 (goto-char tmp-end)
5056 (setq tmp-end (point-marker))) 5047 (setq tmp-end (point-marker)))
5057 (if cperl-indent-region-fix-constructs 5048 (if cperl-indent-region-fix-constructs
5058 (cperl-fix-line-spacing tmp-end)) 5049 (cperl-fix-line-spacing tmp-end))
5059 (cperl-indent-region (point) tmp-end)))) 5050 (cperl-indent-region (point) tmp-end))))
5062 "Improve whitespace in a conditional/loop construct. 5053 "Improve whitespace in a conditional/loop construct.
5063 Returns some position at the last line." 5054 Returns some position at the last line."
5064 (interactive) 5055 (interactive)
5065 (or end 5056 (or end
5066 (setq end (point-max))) 5057 (setq end (point-max)))
5067 (let ((ee (save-excursion (end-of-line) (point))) 5058 (let ((ee (point-at-eol))
5068 (cperl-indent-region-fix-constructs 5059 (cperl-indent-region-fix-constructs
5069 (or cperl-indent-region-fix-constructs 1)) 5060 (or cperl-indent-region-fix-constructs 1))
5070 p pp ml have-brace ret) 5061 p pp ml have-brace ret)
5071 (save-excursion 5062 (save-excursion
5072 (beginning-of-line) 5063 (beginning-of-line)
5215 (insert "\n") 5206 (insert "\n")
5216 (setq ret (point)) 5207 (setq ret (point))
5217 (if (cperl-indent-line parse-data) 5208 (if (cperl-indent-line parse-data)
5218 (setq ret (cperl-fix-line-spacing end parse-data))))))))))) 5209 (setq ret (cperl-fix-line-spacing end parse-data)))))))))))
5219 (beginning-of-line) 5210 (beginning-of-line)
5220 (setq p (point) pp (save-excursion (end-of-line) (point))) ; May be different from ee. 5211 (setq p (point) pp (point-at-eol)) ; May be different from ee.
5221 ;; Now check whether there is a hanging `}' 5212 ;; Now check whether there is a hanging `}'
5222 ;; Looking at: 5213 ;; Looking at:
5223 ;; } blah 5214 ;; } blah
5224 (if (and 5215 (if (and
5225 cperl-fix-hanging-brace-when-indent 5216 cperl-fix-hanging-brace-when-indent
7477 (defun cperl-word-at-point-hard () 7468 (defun cperl-word-at-point-hard ()
7478 ;; Does not save-excursion 7469 ;; Does not save-excursion
7479 ;; Get to the something meaningful 7470 ;; Get to the something meaningful
7480 (or (eobp) (eolp) (forward-char 1)) 7471 (or (eobp) (eolp) (forward-char 1))
7481 (re-search-backward "[-a-zA-Z0-9_:!&*+,-./<=>?\\\\^|~$%@]" 7472 (re-search-backward "[-a-zA-Z0-9_:!&*+,-./<=>?\\\\^|~$%@]"
7482 (save-excursion (beginning-of-line) (point)) 7473 (point-at-bol)
7483 'to-beg) 7474 'to-beg)
7484 ;; (cond 7475 ;; (cond
7485 ;; ((or (eobp) (looking-at "[][ \t\n{}();,]")) ; Not at a symbol 7476 ;; ((or (eobp) (looking-at "[][ \t\n{}();,]")) ; Not at a symbol
7486 ;; (skip-chars-backward " \n\t\r({[]});,") 7477 ;; (skip-chars-backward " \n\t\r({[]});,")
7487 ;; (or (bobp) (backward-char 1)))) 7478 ;; (or (bobp) (backward-char 1))))
8997 ;; continue standard unloading 8988 ;; continue standard unloading
8998 nil) 8989 nil)
8999 8990
9000 (provide 'cperl-mode) 8991 (provide 'cperl-mode)
9001 8992
9002 ;; arch-tag: 42e5b19b-e187-4537-929f-1a7408980ce6
9003 ;;; cperl-mode.el ends here 8993 ;;; cperl-mode.el ends here