Browse Source

Format code-formatting.el, smerge colors, keys

master
Macoy Madson 2 years ago
parent
commit
dd68739fd4
  1. 67
      Emacs/code-formatting.el
  2. 3
      Emacs/tags-and-autocompletion.el
  3. 7
      Emacs/visual-late.el

67
Emacs/code-formatting.el

@ -2,9 +2,9 @@
;; C indentation settings
;; bsd AKA Allman https://www.emacswiki.org/emacs/IndentingC
(setq-default c-default-style "bsd"
c-basic-offset 4
tab-width 4
indent-tabs-mode t)
c-basic-offset 4
tab-width 4
indent-tabs-mode t)
;; Doesn't quite work
;; (defun infer-indentation-style ()
@ -13,11 +13,11 @@
;; (let ((space-count (how-many "^ " (point-min) (point-max)))
;; (tab-count (how-many "^\t" (point-min) (point-max))))
;; (if (> space-count tab-count)
;; ;; ((message "Indent using space")
;; (setq indent-tabs-mode nil))
;; ;; ((message "Indent using space")
;; (setq indent-tabs-mode nil))
;; (if (> tab-count space-count)
;; ;; ((message "Indent using tab")
;; (setq indent-tabs-mode t))))
;; ;; ((message "Indent using tab")
;; (setq indent-tabs-mode t))))
;; (add-hook 'c-mode-common-hook
;; (lambda () (setq indent-tabs-mode nil)
@ -25,48 +25,37 @@
;; (add-hook 'lisp-mode-hook
;; (lambda () (setq indent-tabs-mode nil)
;; (infer-indentation-style)))
;; (infer-indentation-style)))
;; Clang format
;; Looks for .clang-format in project dir
(when (require 'clang-format)
(defun macoy-clang-format-region-or-buffer ()
"Format the region if one is selected, otherwise format the buffer"
(interactive)
(save-excursion
(if (use-region-p)
(call-interactively 'clang-format-region)
(call-interactively 'clang-format-buffer)
)
)
)
"Format the region if one is selected, otherwise format the buffer"
(interactive)
(save-excursion
(if (use-region-p)
(call-interactively 'clang-format-region)
(call-interactively 'clang-format-buffer))))
(defun macoy-clang-format-paragraph ()
"Format the block/paragraph"
(interactive)
(save-excursion
(unless (use-region-p)
(mark-paragraph)
)
(when (use-region-p)
(call-interactively 'clang-format-region)
)
)
)
"Format the block/paragraph"
(interactive)
(save-excursion
(unless (use-region-p)
(mark-paragraph))
(when (use-region-p)
(call-interactively 'clang-format-region))))
(defun macoy-clang-format-function ()
"Format the function"
(interactive)
(save-excursion
(unless (use-region-p)
(mark-defun)
)
(when (use-region-p)
(call-interactively 'clang-format-region)
)
)
)
"Format the function"
(interactive)
(save-excursion
(unless (use-region-p)
(mark-defun))
(when (use-region-p)
(call-interactively 'clang-format-region))))
(global-set-key (kbd "C-M-a") 'macoy-clang-format-region-or-buffer)
(global-set-key (kbd "C-.") 'macoy-clang-format-paragraph)

3
Emacs/tags-and-autocompletion.el

@ -59,7 +59,10 @@
;; Tags keybinding
(global-set-key (kbd "<f12>") 'xref-find-definitions)
(global-set-key (kbd "M-S-g") 'xref-find-definitions)
(global-set-key (kbd "M-g") 'xref-find-definitions-other-window)
(global-set-key (kbd "C-;") 'xref-find-definitions-other-window)
(global-set-key (kbd "C-:") 'xref-find-definitions)
(global-set-key (kbd "S-<f12>") 'xref-find-apropos)
(global-set-key (kbd "C-S-d") 'macoy-ido-find-tag)

7
Emacs/visual-late.el

@ -120,6 +120,11 @@
(set-face-attribute 'ediff-fine-diff-B nil :background "#2c4a27")
)
(when (require 'smerge-mode)
(set-face-attribute 'smerge-refined-added nil :background "#2c4a27")
(set-face-attribute 'smerge-refined-removed nil :background "#4a2727")
)
;; Make magit's diff look similar/the same as diff-mode
(when (require 'magit)
(set-face-attribute 'magit-diff-added-highlight nil
@ -194,3 +199,5 @@
)
(setq list-matching-lines-face nil)
(set-face-foreground 'escape-glyph (face-foreground 'font-lock-warning-face))

Loading…
Cancel
Save