aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love1997-11-30 12:20:49 +0000
committerDave Love1997-11-30 12:20:49 +0000
commitd4a753f9df90bc1071ebb0f1cf3177614979db96 (patch)
treec3cea3ac175f28cecdacdccbb5c0374a6047f027
parent33165c240f2f2aa1dcaca840cdc2f383bd688726 (diff)
downloademacs-d4a753f9df90bc1071ebb0f1cf3177614979db96.tar.gz
emacs-d4a753f9df90bc1071ebb0f1cf3177614979db96.zip
(indent-for-comment): Check for null `comment-start-skip'.
-rw-r--r--lisp/simple.el79
1 files changed, 41 insertions, 38 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 5e0687ca364..db3340e956f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2392,44 +2392,47 @@ If nil, use `comment-end' instead."
2392 (looking-at "[ \t]*$"))) 2392 (looking-at "[ \t]*$")))
2393 (starter (or (and empty block-comment-start) comment-start)) 2393 (starter (or (and empty block-comment-start) comment-start))
2394 (ender (or (and empty block-comment-end) comment-end))) 2394 (ender (or (and empty block-comment-end) comment-end)))
2395 (if (null starter) 2395 (cond
2396 (error "No comment syntax defined") 2396 ((null starter)
2397 (let* ((eolpos (save-excursion (end-of-line) (point))) 2397 (error "No comment syntax defined"))
2398 cpos indent begpos) 2398 ((null comment-start-skip)
2399 (beginning-of-line) 2399 (error "This mode doesn't define `comment-start-skip'"))
2400 (if (re-search-forward comment-start-skip eolpos 'move) 2400 (t (let* ((eolpos (save-excursion (end-of-line) (point)))
2401 (progn (setq cpos (point-marker)) 2401 cpos indent begpos)
2402 ;; Find the start of the comment delimiter. 2402 (beginning-of-line)
2403 ;; If there were paren-pairs in comment-start-skip, 2403 (if (re-search-forward comment-start-skip eolpos 'move)
2404 ;; position at the end of the first pair. 2404 (progn (setq cpos (point-marker))
2405 (if (match-end 1) 2405 ;; Find the start of the comment delimiter.
2406 (goto-char (match-end 1)) 2406 ;; If there were paren-pairs in comment-start-skip,
2407 ;; If comment-start-skip matched a string with 2407 ;; position at the end of the first pair.
2408 ;; internal whitespace (not final whitespace) then 2408 (if (match-end 1)
2409 ;; the delimiter start at the end of that 2409 (goto-char (match-end 1))
2410 ;; whitespace. Otherwise, it starts at the 2410 ;; If comment-start-skip matched a string with
2411 ;; beginning of what was matched. 2411 ;; internal whitespace (not final whitespace) then
2412 (skip-syntax-backward " " (match-beginning 0)) 2412 ;; the delimiter start at the end of that
2413 (skip-syntax-backward "^ " (match-beginning 0))))) 2413 ;; whitespace. Otherwise, it starts at the
2414 (setq begpos (point)) 2414 ;; beginning of what was matched.
2415 ;; Compute desired indent. 2415 (skip-syntax-backward " " (match-beginning 0))
2416 (if (= (current-column) 2416 (skip-syntax-backward "^ " (match-beginning 0)))))
2417 (setq indent (if comment-indent-hook 2417 (setq begpos (point))
2418 (funcall comment-indent-hook) 2418 ;; Compute desired indent.
2419 (funcall comment-indent-function)))) 2419 (if (= (current-column)
2420 (goto-char begpos) 2420 (setq indent (if comment-indent-hook
2421 ;; If that's different from current, change it. 2421 (funcall comment-indent-hook)
2422 (skip-chars-backward " \t") 2422 (funcall comment-indent-function))))
2423 (delete-region (point) begpos) 2423 (goto-char begpos)
2424 (indent-to indent)) 2424 ;; If that's different from current, change it.
2425 ;; An existing comment? 2425 (skip-chars-backward " \t")
2426 (if cpos 2426 (delete-region (point) begpos)
2427 (progn (goto-char cpos) 2427 (indent-to indent))
2428 (set-marker cpos nil)) 2428 ;; An existing comment?
2429 ;; No, insert one. 2429 (if cpos
2430 (insert starter) 2430 (progn (goto-char cpos)
2431 (save-excursion 2431 (set-marker cpos nil))
2432 (insert ender))))))) 2432 ;; No, insert one.
2433 (insert starter)
2434 (save-excursion
2435 (insert ender))))))))
2433 2436
2434(defun set-comment-column (arg) 2437(defun set-comment-column (arg)
2435 "Set the comment column based on point. 2438 "Set the comment column based on point.