diff options
| author | Joakim Verona | 2013-04-09 00:21:04 +0200 |
|---|---|---|
| committer | Joakim Verona | 2013-04-09 00:21:04 +0200 |
| commit | e25d341cec1ebaee2b96d627d99d4d7b92dee6b0 (patch) | |
| tree | a837c08c8ff2a6054964bd73469f6386368300e7 /lisp/progmodes | |
| parent | 9639da1e26683b6a54d255bb07a24dd6e0fae354 (diff) | |
| parent | 6fcdab68b3e73354fb17f4c8c4f8199d6f63cf30 (diff) | |
| download | emacs-e25d341cec1ebaee2b96d627d99d4d7b92dee6b0.tar.gz emacs-e25d341cec1ebaee2b96d627d99d4d7b92dee6b0.zip | |
xdisp fix
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 55 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 16 | ||||
| -rw-r--r-- | lisp/progmodes/subword.el | 20 |
4 files changed, 61 insertions, 32 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 368b1fc50dc..4fc270792fc 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -2180,32 +2180,45 @@ comment at the start of cc-engine.el for more info." | |||
| 2180 | ;; reduced by buffer changes, and increased by invocations of | 2180 | ;; reduced by buffer changes, and increased by invocations of |
| 2181 | ;; `c-state-literal-at'. FIXME!!! | 2181 | ;; `c-state-literal-at'. FIXME!!! |
| 2182 | 2182 | ||
| 2183 | (defsubst c-state-pp-to-literal (from to) | 2183 | (defsubst c-state-pp-to-literal (from to &optional not-in-delimiter) |
| 2184 | ;; Do a parse-partial-sexp from FROM to TO, returning either | 2184 | ;; Do a parse-partial-sexp from FROM to TO, returning either |
| 2185 | ;; (STATE TYPE (BEG . END)) if TO is in a literal; or | 2185 | ;; (STATE TYPE (BEG . END)) if TO is in a literal; or |
| 2186 | ;; (STATE) otherwise, | 2186 | ;; (STATE) otherwise, |
| 2187 | ;; where STATE is the parsing state at TO, TYPE is the type of the literal | 2187 | ;; where STATE is the parsing state at TO, TYPE is the type of the literal |
| 2188 | ;; (one of 'c, 'c++, 'string) and (BEG . END) is the boundaries of the literal. | 2188 | ;; (one of 'c, 'c++, 'string) and (BEG . END) is the boundaries of the literal. |
| 2189 | ;; | 2189 | ;; |
| 2190 | ;; Unless NOT-IN-DELIMITER is non-nil, when TO is inside a two-character | ||
| 2191 | ;; comment opener, this is recognized as being in a comment literal. | ||
| 2192 | ;; | ||
| 2190 | ;; Only elements 3 (in a string), 4 (in a comment), 5 (following a quote), | 2193 | ;; Only elements 3 (in a string), 4 (in a comment), 5 (following a quote), |
| 2191 | ;; 7 (comment type) and 8 (start of comment/string) (and possibly 9) of | 2194 | ;; 7 (comment type) and 8 (start of comment/string) (and possibly 9) of |
| 2192 | ;; STATE are valid. | 2195 | ;; STATE are valid. |
| 2193 | (save-excursion | 2196 | (save-excursion |
| 2194 | (let ((s (parse-partial-sexp from to)) | 2197 | (let ((s (parse-partial-sexp from to)) |
| 2195 | ty) | 2198 | ty co-st) |
| 2196 | (when (or (nth 3 s) (nth 4 s)) ; in a string or comment | 2199 | (cond |
| 2200 | ((or (nth 3 s) (nth 4 s)) ; in a string or comment | ||
| 2197 | (setq ty (cond | 2201 | (setq ty (cond |
| 2198 | ((nth 3 s) 'string) | 2202 | ((nth 3 s) 'string) |
| 2199 | ((eq (nth 7 s) t) 'c++) | 2203 | ((nth 7 s) 'c++) |
| 2200 | (t 'c))) | 2204 | (t 'c))) |
| 2201 | (parse-partial-sexp (point) (point-max) | 2205 | (parse-partial-sexp (point) (point-max) |
| 2202 | nil ; TARGETDEPTH | 2206 | nil ; TARGETDEPTH |
| 2203 | nil ; STOPBEFORE | 2207 | nil ; STOPBEFORE |
| 2204 | s ; OLDSTATE | 2208 | s ; OLDSTATE |
| 2205 | 'syntax-table)) ; stop at end of literal | 2209 | 'syntax-table) ; stop at end of literal |
| 2206 | (if ty | 2210 | `(,s ,ty (,(nth 8 s) . ,(point)))) |
| 2207 | `(,s ,ty (,(nth 8 s) . ,(point))) | 2211 | |
| 2208 | `(,s))))) | 2212 | ((and (not not-in-delimiter) ; inside a comment starter |
| 2213 | (not (bobp)) | ||
| 2214 | (progn (backward-char) | ||
| 2215 | (looking-at c-comment-start-regexp))) | ||
| 2216 | (setq ty (if (looking-at c-block-comment-start-regexp) 'c 'c++) | ||
| 2217 | co-st (point)) | ||
| 2218 | (forward-comment 1) | ||
| 2219 | `(,s ,ty (,co-st . ,(point)))) | ||
| 2220 | |||
| 2221 | (t `(,s)))))) | ||
| 2209 | 2222 | ||
| 2210 | (defun c-state-safe-place (here) | 2223 | (defun c-state-safe-place (here) |
| 2211 | ;; Return a buffer position before HERE which is "safe", i.e. outside any | 2224 | ;; Return a buffer position before HERE which is "safe", i.e. outside any |
| @@ -3143,10 +3156,13 @@ comment at the start of cc-engine.el for more info." | |||
| 3143 | ;; This function is called from c-after-change. | 3156 | ;; This function is called from c-after-change. |
| 3144 | 3157 | ||
| 3145 | ;; The caches of non-literals: | 3158 | ;; The caches of non-literals: |
| 3146 | (if (< here c-state-nonlit-pos-cache-limit) | 3159 | ;; Note that we use "<=" for the possibility of the second char of a two-char |
| 3147 | (setq c-state-nonlit-pos-cache-limit here)) | 3160 | ;; comment opener being typed; this would invalidate any cache position at |
| 3148 | (if (< here c-state-semi-nonlit-pos-cache-limit) | 3161 | ;; HERE. |
| 3149 | (setq c-state-semi-nonlit-pos-cache-limit here)) | 3162 | (if (<= here c-state-nonlit-pos-cache-limit) |
| 3163 | (setq c-state-nonlit-pos-cache-limit (1- here))) | ||
| 3164 | (if (<= here c-state-semi-nonlit-pos-cache-limit) | ||
| 3165 | (setq c-state-semi-nonlit-pos-cache-limit (1- here))) | ||
| 3150 | 3166 | ||
| 3151 | ;; `c-state-cache': | 3167 | ;; `c-state-cache': |
| 3152 | ;; Case 1: if `here' is in a literal containing point-min, everything | 3168 | ;; Case 1: if `here' is in a literal containing point-min, everything |
| @@ -4444,19 +4460,12 @@ comment at the start of cc-engine.el for more info." | |||
| 4444 | (lim (or lim (c-state-semi-safe-place pos))) | 4460 | (lim (or lim (c-state-semi-safe-place pos))) |
| 4445 | (pp-to-lit (save-restriction | 4461 | (pp-to-lit (save-restriction |
| 4446 | (widen) | 4462 | (widen) |
| 4447 | (c-state-pp-to-literal lim pos))) | 4463 | (c-state-pp-to-literal lim pos not-in-delimiter))) |
| 4448 | (state (car pp-to-lit)) | 4464 | (state (car pp-to-lit)) |
| 4449 | (lit-limits (car (cddr pp-to-lit)))) | 4465 | (lit-limits (car (cddr pp-to-lit)))) |
| 4450 | 4466 | ||
| 4451 | (cond | 4467 | (cond |
| 4452 | (lit-limits) | 4468 | (lit-limits) |
| 4453 | ((and (not not-in-delimiter) | ||
| 4454 | (not (elt state 5)) | ||
| 4455 | (eq (char-before) ?/) | ||
| 4456 | (looking-at "[/*]")) ; FIXME!!! use c-line/block-comment-starter. 2008-09-28. | ||
| 4457 | ;; We're standing in a comment starter. | ||
| 4458 | (backward-char 1) | ||
| 4459 | (cons (point) (progn (c-forward-single-comment) (point)))) | ||
| 4460 | 4469 | ||
| 4461 | (near | 4470 | (near |
| 4462 | (goto-char pos) | 4471 | (goto-char pos) |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index f6c47f5bb4d..83343b23014 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -2486,7 +2486,7 @@ need for `pike-font-lock-extra-types'.") | |||
| 2486 | (setq comment-beg nil)) | 2486 | (setq comment-beg nil)) |
| 2487 | (setq region-beg comment-beg)) | 2487 | (setq region-beg comment-beg)) |
| 2488 | 2488 | ||
| 2489 | (if (eq (elt (parse-partial-sexp comment-beg (+ comment-beg 2)) 7) t) | 2489 | (if (elt (parse-partial-sexp comment-beg (+ comment-beg 2)) 7) |
| 2490 | ;; Collect a sequence of doc style line comments. | 2490 | ;; Collect a sequence of doc style line comments. |
| 2491 | (progn | 2491 | (progn |
| 2492 | (goto-char comment-beg) | 2492 | (goto-char comment-beg) |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index f0f67d01845..d1009534e49 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -638,6 +638,12 @@ It makes underscores and dots word constituent chars.") | |||
| 638 | These make `python-indent-calculate-indentation' subtract the value of | 638 | These make `python-indent-calculate-indentation' subtract the value of |
| 639 | `python-indent-offset'.") | 639 | `python-indent-offset'.") |
| 640 | 640 | ||
| 641 | (defvar python-indent-block-enders '("return" "pass") | ||
| 642 | "List of words that mark the end of a block. | ||
| 643 | These make `python-indent-calculate-indentation' subtract the | ||
| 644 | value of `python-indent-offset' when `python-indent-context' is | ||
| 645 | AFTER-LINE.") | ||
| 646 | |||
| 641 | (defun python-indent-guess-indent-offset () | 647 | (defun python-indent-guess-indent-offset () |
| 642 | "Guess and set `python-indent-offset' for the current buffer." | 648 | "Guess and set `python-indent-offset' for the current buffer." |
| 643 | (interactive) | 649 | (interactive) |
| @@ -763,9 +769,13 @@ START is the buffer position where the sexp starts." | |||
| 763 | (save-excursion | 769 | (save-excursion |
| 764 | (goto-char context-start) | 770 | (goto-char context-start) |
| 765 | (current-indentation)) | 771 | (current-indentation)) |
| 766 | (if (progn | 772 | (if (or (save-excursion |
| 767 | (back-to-indentation) | 773 | (back-to-indentation) |
| 768 | (looking-at (regexp-opt python-indent-dedenters))) | 774 | (looking-at (regexp-opt python-indent-dedenters))) |
| 775 | (save-excursion | ||
| 776 | (python-util-forward-comment -1) | ||
| 777 | (python-nav-beginning-of-statement) | ||
| 778 | (member (current-word) python-indent-block-enders))) | ||
| 769 | python-indent-offset | 779 | python-indent-offset |
| 770 | 0))) | 780 | 0))) |
| 771 | ;; When inside of a string, do nothing. just use the current | 781 | ;; When inside of a string, do nothing. just use the current |
diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el index 24abfa8a053..6cb4713885e 100644 --- a/lisp/progmodes/subword.el +++ b/lisp/progmodes/subword.el | |||
| @@ -154,7 +154,7 @@ as words. | |||
| 154 | "Do the same as `forward-word' but on subwords. | 154 | "Do the same as `forward-word' but on subwords. |
| 155 | See the command `subword-mode' for a description of subwords. | 155 | See the command `subword-mode' for a description of subwords. |
| 156 | Optional argument ARG is the same as for `forward-word'." | 156 | Optional argument ARG is the same as for `forward-word'." |
| 157 | (interactive "p") | 157 | (interactive "^p") |
| 158 | (unless arg (setq arg 1)) | 158 | (unless arg (setq arg 1)) |
| 159 | (cond | 159 | (cond |
| 160 | ((< 0 arg) | 160 | ((< 0 arg) |
| @@ -168,16 +168,26 @@ Optional argument ARG is the same as for `forward-word'." | |||
| 168 | 168 | ||
| 169 | (put 'subword-forward 'CUA 'move) | 169 | (put 'subword-forward 'CUA 'move) |
| 170 | 170 | ||
| 171 | (defalias 'subword-right 'subword-forward) | ||
| 172 | |||
| 173 | (defun subword-backward (&optional arg) | 171 | (defun subword-backward (&optional arg) |
| 174 | "Do the same as `backward-word' but on subwords. | 172 | "Do the same as `backward-word' but on subwords. |
| 175 | See the command `subword-mode' for a description of subwords. | 173 | See the command `subword-mode' for a description of subwords. |
| 176 | Optional argument ARG is the same as for `backward-word'." | 174 | Optional argument ARG is the same as for `backward-word'." |
| 177 | (interactive "p") | 175 | (interactive "^p") |
| 178 | (subword-forward (- (or arg 1)))) | 176 | (subword-forward (- (or arg 1)))) |
| 179 | 177 | ||
| 180 | (defalias 'subword-left 'subword-backward) | 178 | (defun subword-right (&optional arg) |
| 179 | "Do the same as `right-word' but on subwords." | ||
| 180 | (interactive "^p") | ||
| 181 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | ||
| 182 | (subword-forward arg) | ||
| 183 | (subword-backward arg))) | ||
| 184 | |||
| 185 | (defun subword-left (&optional arg) | ||
| 186 | "Do the same as `left-word' but on subwords." | ||
| 187 | (interactive "^p") | ||
| 188 | (if (eq (current-bidi-paragraph-direction) 'left-to-right) | ||
| 189 | (subword-backward arg) | ||
| 190 | (subword-forward arg))) | ||
| 181 | 191 | ||
| 182 | (defun subword-mark (arg) | 192 | (defun subword-mark (arg) |
| 183 | "Do the same as `mark-word' but on subwords. | 193 | "Do the same as `mark-word' but on subwords. |