diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-09-08 22:41:55 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-09-08 22:41:55 +0200 |
commit | 395e55129c78e6507342d906030061bf97aa9223 (patch) | |
tree | 940db7a3d4fcaad9e6b4b1adcf237923885ce4fc | |
parent | d21529788a6f591965441d062672f871aacd8711 (diff) |
emacs: Configure auto newline insertion
-rw-r--r-- | .config/emacs/init.el | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/.config/emacs/init.el b/.config/emacs/init.el index aad1603..8bebd23 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -667,9 +667,18 @@ font name, font weight, and font height in that order.") '(after) '(before after))) -(defun x-c (_syn _pos) - (message "OMG") - '(before)) +(defun x-c-semi&comma-after-return () + "‘c-mode’ criteria to avoid automatic newline insertion after entering +a semicolon following a return statement." + (catch 'return + (let ((end-position (point))) + (save-excursion + (goto-char (line-beginning-position)) + (save-match-data + (while (re-search-forward "\\<return\\>" end-position 'noerror) + (when (eq (get-text-property (1- (point)) 'face) + 'font-lock-keyword-face) + (throw 'return 'stop)))))))) (c-add-style "mango" @@ -680,6 +689,10 @@ font name, font weight, and font height in that order.") (c-block-comment-prefix . "") (c-comment-only-line-offset . 0) (c-label-minimum-indentation . 0) + (c-hanging-semi&comma-criteria . (x-c-semi&comma-after-return + c-semi&comma-inside-parenlist + c-semi&comma-no-newlines-before-nonblanks + c-semi&comma-no-newlines-for-oneline-inliners)) (c-cleanup-list . (brace-else-brace brace-elseif-brace brace-catch-brace |