Last active
July 14, 2018 04:11
-
-
Save c02y/53f3dc97f2c985e89b86095d6a27a1c3 to your computer and use it in GitHub Desktop.
align comments and macro pf multiple lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; align-regexp with space instead tab | |
(defadvice align-regexp (around align-regexp-with-spaces activate) | |
(let ((indent-tabs-mode nil)) | |
ad-do-it)) | |
(defalias 'ar #'align-regexp) | |
(defadvice align (around align-with-spaces activate) | |
(let ((indent-tabs-mode nil)) | |
ad-do-it)) | |
(defun align-c-comments (beginning end) | |
"Align instances of // or /* */ within marked region." | |
(interactive "*r") | |
(let (indent-tabs-mode align-to-tab-stop) | |
(align-regexp beginning end "\\(\\s-*\\)[//|/*]"))) | |
(defun align-c-macros (beginning end) | |
"Align macros within marked region" | |
(interactive "*r") | |
(progn | |
(align beginning end) | |
(untabify beginning end))) | |
(require 'cc-mode) ;; c-mode-map | |
(dolist (m (list c-mode-map c++-mode-map)) | |
(bind-keys :map m | |
:prefix-map align-prefix-map | |
:prefix "C-c a" | |
("c" . align-c-comments) | |
("m" . align-c-macros))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
("a" . align)
("r" . align-regexp)