# HG changeset patch # User Stefan Monnier # Date 1008366809 0 # Node ID 74a3864ffe9ac1cc36742fb8afc424724b1437cf # Parent 25915136cfdd606b2bfdd1ba8cf39c750c67f9d7 (comment-indent): Jump to the middle of empty comments. diff -r 25915136cfdd -r 74a3864ffe9a lisp/newcomment.el --- a/lisp/newcomment.el Fri Dec 14 19:58:10 2001 +0000 +++ b/lisp/newcomment.el Fri Dec 14 21:53:29 2001 +0000 @@ -5,7 +5,7 @@ ;; Author: code extracted from Emacs-20's simple.el ;; Maintainer: Stefan Monnier ;; Keywords: comment uncomment -;; Revision: $Id: newcomment.el,v 1.41 2001/11/29 21:29:36 monnier Exp $ +;; Revision: $Id: newcomment.el,v 1.42 2001/12/02 04:19:32 monnier Exp $ ;; This file is part of GNU Emacs. @@ -30,7 +30,6 @@ ;;; Bugs: -;; - comment-indent on /* */ jumps to /* ><*/ instead of /* >< */. ;; - nested comments in sgml-mode are not properly quoted. ;; - single-char nestable comment-start can only do the "\\s<+" stuff ;; if the corresponding closing marker happens to be right. @@ -450,7 +449,15 @@ (begpos (comment-search-forward eolpos t)) cpos indent) ;; An existing comment? - (if begpos (setq cpos (point-marker)) + (if begpos + (progn + (if (and (not (looking-at "[\t\n ]")) + (looking-at comment-end-skip)) + ;; The comment is empty and we have skipped all its space + ;; and landed right before the comment-ender: + ;; Go back to the middle of the space. + (forward-char (/ (skip-chars-backward " \t") -2))) + (setq cpos (point-marker))) ;; If none, insert one. (save-excursion ;; Some comment-indent-function insist on not moving comments that