Browse Source

Added key value generic mode, web mode, codesearch changes

* I installed Web-mode for use at my work (better templating support
* Added quit command to select-search
* Fixed codesearch multiple files filter regex
* Added custom syntax for key value files (for work, but I'm keeping
  it for future reference)
master 4 years ago
  1. 95
  2. 1


@ -91,18 +91,19 @@
;; - Find file in dir (basically ido find file but actually useful; how does it work?)
;; - Macoy-Codesearch should have something for whole word searches as well as sanitizing regex symbols
;; I tried to do this but it doesn't work :/
;;*- IMPORTANT Codesearch ignore autogenerated files (maybe during building index?)
;; - Codesearch doesn't seem to actually be updating during index (wtf?)
;; - Isearch: Make reversing the isearch not find the same thing again
;; - Isearch: Always put cursor at end of search (try searching backwards; it'll put it at the front)
;; - Isearch: If you paste a thing into isearch, then go up or down a bit, then hit backspace, it returns
;; to the last search until you get to the original place, then it clears the search. This is confusing :(
;; - Mysterious thing which deletes the last half of the buffer (c-remove-stale-state-cache-backwards?)
;; - Codesearch: Regex filtering doesn't work (try e.g. "myfunc(")
;; - Codesearch: Regex filtering doesn't work (try e.g. "myfunc(") (TODO: Retest this with the new "quotes")
;; - Fix window splitting on Linux/4k
;; - Feature: filter lines in file (good for codesearch results etc.). Extra cool = as you type (hard) (install something for this)
;; keep-lines does this, although not as you type, and requires modifying the buffer (make a func which dupes and does it)
;; Use (clone-indirect-buffer) (
;; - Treacherous: vc-annotate uses the revision which the buffer has, which if you commit from DSVN
;; does not update (i.e. look at the mode line revision). You need to revert the buffer then do vc-annotate to see the true state
;; - Isearch: Customize colors
;; Criticism improvements:
;; - [DONE] Select word at point
@ -122,6 +123,8 @@
;; C-q = quoted-insert "insert the next character, whatever it is" e.g. useful for inserting a tab
;; describe-char with cursor over character will say where the font face came from (useful for theming)
;; Use ibuffer to select and kill many buffers. kill-some-buffers is also okay
;; Use ediff-revision to easily manipulate working edits
;; Use re-builder to create a regex by seeing the results of it in the current buffer (super awesome)
@ -596,6 +599,8 @@ If there's a string at point, offer that as a default."
;; Internet search
(define-key map (kbd "i") (lambda () (interactive) (macoy-select-do-search
(define-key map (kbd "q") (lambda () (interactive) (kill-buffer macoy-select-search-buf-name)))
"macoy-select-search-minor-mode keymap.")
@ -726,28 +731,10 @@ If there's a string at point, offer that as a default."
(define-key macoy-codesearch-mode-map (kbd "n") #'compilation-next-error)
(define-key macoy-codesearch-mode-map (kbd "f") 'macoy-filter-buffer)
;; The filter which will apply to codesearch results. Things matching this regex will be removed
;; The filter which will apply to codesearch results. Things matching this regex will be removed.
;; This is useful for e.g. filtering autogenerated code files
;; Note that this will also remove code lines which match this pattern, so make the regex robust to that
(setq macoy-codesearch-ignore-lines-pattern "_ast\.")
;; This should work but doesn't :( (note that you may need to add -E below)
;; (setq macoy-codesearch-ignore-lines-pattern "'_ast\.|autogen'")
;; (defun macoy-codesearch-search-with-filter (pattern)
;; (interactive
;; (list
;; (read-string "Search: " (thing-at-point 'symbol))))
;; ;; Use the compile command so we have nice clickable links
;; ;; Note that without regexp-quote, this does support regexes. I don't want them in my case
;; ;; Args explanation: -n (Line numbers) -i (ignore case)
;; ;; Output Codesearch results to a temporary file, filter out lines, then clean up the temp file
;; (compilation-start (format "%s -n -i %s > .temp-codesearch.txt && grep -v %s .temp-codesearch.txt && rm .temp-codesearch.txt"
;; codesearch-csearch-exe
;; (regexp-quote pattern)
;; macoy-codesearch-ignore-lines-pattern)
;; #'macoy-codesearch-mode
;; `(lambda (mode-name) , "*Codesearch*")
;; )
;; )
(setq macoy-codesearch-ignore-lines-pattern "_ast\.|_autogen|\.wiki")
(defun macoy-codesearch-search-with-filter-directory (pattern directory)
@ -762,7 +749,7 @@ If there's a string at point, offer that as a default."
(set (make-local-variable 'compilation-environment) nil)
;; This temp-file thing sucks but seems necessary for Windows
(compilation-start (format "%s -n -i %s > %s && grep -v %s %s && rm %s"
(compilation-start (format "%s -n -i \"%s\" > %s && grep -i -E -v \"%s\" %s && rm %s"
(regexp-quote pattern)
@ -904,7 +891,7 @@ If there's a string at point, offer that as a default."
;; Note that these are both subprocesses so they will run at the same time
;; Tags keybinding
(global-set-key (kbd "<f12>") 'xref-find-definitions)
@ -1107,6 +1094,63 @@ If there's a string at point, offer that as a default."
(browse-url-of-file (expand-file-name default-directory))
(error "No `default-directory' to open")))
;; Web tech
;; This is for better syntax highlighting when editing templated web files (e.g. files with Nunjucks)
;; Only enabled at work because I don't use templates at home
(when (string-equal (user-login-name) "mmadson")
;; TODO: Customize colors (see "Syntax highlighting")
(require 'web-mode)
;; I like to manually enable rainbow-mode if I want to see colors (this might not work...)
(setq web-mode-enable-css-colorization nil)
;; Associate web files with web-mode
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js?\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.css?\\'" . web-mode))
;; I use Nunjucks which is in the Django family
(setq web-mode-engines-alist
'(("django" . "\\.html\\'")
("django" . "\\.js\\.")
("django" . "\\.css\\.")
;; Custom syntax definitions
;; Data files
(define-generic-mode 'macoy-key-value-def-mode
;; Comments
;; Keywords
"End" "Name"
;; Font locks
;; Numerical constants
("\\_<[\-0-9e\.]+\\_>" . font-lock-constant-face)
;; Generic "Key Value" match (I'm proud of this :) )
;; I use variable here because it's setting a variable on the struct with match's name
;; (plus it looks different in a way that I like)
("^[[:blank:]]*+[[:alnum:]]+[[:blank:]]+*+" . font-lock-variable-name-face)
;; Functions. The 1 here means only highlight the first group
("\\([[:alnum:]]*\\)\(" 1 font-lock-function-name-face)
;; Files to use this mode
;; Function list
;; Source control
@ -1208,6 +1252,7 @@ If there's a string at point, offer that as a default."
(defun buildStopIncredibuild ()
"Stop Incredibuild"
(message "Stopping build")
(start-process "Build" "*Build-out*" "BuildConsole.exe"


@ -27,6 +27,7 @@ smex 3.0 M-x interface with Ido-style fuzzy matching.
smooth-scrolling 20161002.1249 Make emacs scroll smoothly
sublime-themes 20170606.1144 A collection of themes based on Sublime Text
swiper 20180402.1857 Isearch with an overview. Oh, man!
xah-find 20180310.450 find replace in pure emacs lisp. Purpose similar to grep/sed.
yasnippet 20180412.1548 Yet another snippet extension for Emacs.
zenburn-theme 2.1 A low contrast color theme for Emacs.