Update elfeed feeds list + clean python mode + Fix c-mode indentation issue.

This commit is contained in:
2022-01-30 11:49:42 +01:00
parent 4ca83022dc
commit dd3c5be63f
3 changed files with 26 additions and 53 deletions

View File

@@ -4,13 +4,14 @@
(require 'cl)
(require 'lsp)
(require 'cc-vars)
(require 'flycheck)
(defun user--c-format-before-save ()
"C/C++ cleanup and format before save buffer."
(delete-trailing-whitespace)
;; Format buffer.
(indent-region (point-min) (point-max) nil)
)
(indent-region (point-min) (point-max) nil))
;; From https://www.emacswiki.org/emacs/CompileCommand
(defun* user--c-get-closest-pathname (&optional (file "Makefile"))
@@ -31,10 +32,13 @@ of FILE in the current directory, suitable for creation"
(defun user--c-mode-common-hook ()
"C-like languages mode hook."
(message "user--c-mode-common-hook BEG")
(add-many-to-list 'c-default-style '(c-mode . "bsd") '(c++-mode . "bsd"))
(setq tab-width 4)
(setq-local tab-width 4)
(setq-local c-basic-offset 4)
;; Propertize "#if 0" regions as comments.
(font-lock-add-keywords
nil
@@ -47,7 +51,7 @@ of FILE in the current directory, suitable for creation"
(format "make -C %s" (directory-file-name (file-name-directory (user--c-get-closest-pathname)))))
;; Avoid to hit enter after compile-command to build.
(setq compilation-read-command nil)
;; Separate camel-case into separate words.
(subword-mode t)
@@ -56,11 +60,14 @@ of FILE in the current directory, suitable for creation"
(paren-toggle-open-paren-context t))
(setq flycheck-checker-error-threshold 1000)
(setq flycheck-local-checkers '((lsp . ((next-checkers . (flawfinder))))))
;; (flycheck-add-next-checker 'clang-analyzer 'flawfinder)
(user/smartparens-enable))
(user/smartparens-enable)
(message "user--c-mode-common-hook END")
)
(defun user/c-mode-font-lock-if0 (limit)
"Propertize '#if 0' regions, up to LIMIT in size, as comments."
@@ -100,7 +107,7 @@ of FILE in the current directory, suitable for creation"
(c-mode-common-hook . hs-minor-mode)
(c-mode-common-hook . lsp-deferred)
(c-mode-common-hook . (lambda ()
(add-hook 'before-save-hook #'user--c-format-before-save nil t)))
(add-hook 'before-save-hook #'user--c-format-before-save nil t)))
:init
;; Detect if inside a C++ header file.
(add-magic-mode 'c++-mode 'user/c++-header-file-p)
@@ -112,7 +119,6 @@ of FILE in the current directory, suitable for creation"
;; https://github.com/emacs-mirror/emacs/blob/master/lisp/progmodes/cc-vars.el
;; user customization variables for CC Mod
(use-package cc-vars
:disabled
:ensure cc-mode
:config
(validate-setq
@@ -146,7 +152,7 @@ of FILE in the current directory, suitable for creation"
(validate-setq
ccls-initialization-options
'(:index (:comments 1) :cacheFormat "msgpack")))
;; https://github.com/alexmurray/flycheck-flawfinder
;; Integrate flawfinder with flycheck to automatically check for possible security weaknesses
;; within your C/C++ code on the fly.