Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So, if I understand what you want, you just want the capability to add one extra level of indentation based on some token. This is quite possible by using your own lineup function, you can find more info in the <strong>"CC Mode" Manual</strong> - specifically check out the section:</p> <p><strong>(ccmode) Line-Up Functions</strong></p> <p>Here's the custom lineup function, it checks if the comment starts with your special sequence (I used //+), if so it adds an extra level (returning the plus symbol). Otherwise, we ignore it and treat it as the comment is normally indented (returning nil). As you can probably imagine, using a lineup function, we can get as tricky as one likes - such as multiple tokens or nested levels.</p> <pre><code>(defun brian-comment-offset (langelem) (save-excursion (back-to-indentation) (cond ((re-search-forward (regexp-quote "//+") (point-at-eol) t) '+) (t nil)))) </code></pre> <p>To use it, you need to set the offset alias variable <strong>comment-intro</strong> to run this function. I do this by creating my own c style as shown below. I would recomend you copy whatever your current style is, and just modify/add the <strong>comment-intro</strong> alist only.</p> <pre><code>(c-add-style "briancpp" '((c-basic-offset . 2) (c-comment-only-line-offset . 0) (c-offsets-alist (comment-intro . brian-comment-offset) ; Here's our workhorse (defun-open . 0) (defun-close . 0) (statement-block-intro . +) (substatement-open . 0) (substatement-label . 0) (label . 0) (statement-cont . +) (inline-open . 0) (inline-close . 0) (innamespace . 0)))) (add-hook 'c++-mode-hook (lambda () (c-set-style "briancpp"))) </code></pre> <p>And here's what it looks like in action:</p> <p><img src="https://i.stack.imgur.com/WnBBV.png" alt="CC Mode Extra Indents ScreenShot"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload