Browse Source

Improved codesearch interface, many todos, function moving

* Codesearch now has a better interface. It also sanitizes strings so
they are no longer regexes. This is essential to how I use the
system (usually just using marked regions as the search)
* Swap Ag and Codesearch keybinds
* Going to beginning/end of defun is now language-agnostic
master
Macoy Madson 4 years ago
parent
commit
759c3e2cd5
  1. 109
      Emacs/emacsConfig.txt

109
Emacs/emacsConfig.txt

@ -43,7 +43,7 @@
;; ...then set codesearch-csearch-exe and codesearch-cindex-exe to their respective executable locations
;; Search for codesearch in this file to adjust indexing settings
;;
;; TODO (there are more scattered around this file):
;; TODO (there are more scattered around this file; * = more important):
;; - TAGS has to be set up per-project; doesn't allow cross-repository finding afaik
;; It does, you just need to set tags-table-list.
;; See https://www.gnu.org/software/emacs/manual/html_node/emacs/Select-Tags-Table.html
@ -53,48 +53,59 @@
;; - Build system selection via Ido custom list (like Sublime's C-S-b)
;; - Determine what smooth-scrolling actually does (if anything)
;; - Copy line when nothing is marked
;; - Ido jump to file anywhere does more harm than good (especially when creating new files)
;; - Python indentation is godawful
;; - Multiple cursors copy and cut when whole line selected
;; - Ido jump to file anywhere does more harm than good (especially when creating new files)
;; - Python indentation is troublesome in originally poorly formatted files
;; - Make C-g quit selection and multiple cursors if mc is active
;; - Auto-install packages just by loading .emacs (use-package? https://github.com/jwiegley/use-package)
;; - Auto-install packages just by loading .emacs
;; (use-package? https://github.com/jwiegley/use-package but I don't want to get locked in)
;; - Shortcuts:
;; Toggle whitespace mode
;; Swap windows
;; Swap windows (see http://whattheemacsd.com/ rotate windows?)
;; - Indent-tabs-mode only in C/C++
;; - Auto-select actual struct definition when multiple xref results
;; - If use-region, C-k should delete region instead of line
;; - Make git-commit-mode and with-editor-mode not use C-c (somehow raise priority of my-keys? Or rebind?)
;; - Powerline: Make mode colors comments so they aren't as bright (same color as percent complete)
;; - tags-query-replace use marked for tag to replace
;; - Recover from commit failed backup command
;; - Recover from commit failed backup command (or at least quick-open recovery file)
;; - Fix windows OpenSSL/TLS support
;; - Fix multiple-cursors slow parenthesis completion (due to pause to show matching?)
;; - Build system management (use (funcall (intern "my-func-name")) to ido select build system?)
;; - Jump copy thing at point then paste back at start
;; e.g. the macro would avy prompt, jump to destination, copy it, then go back and paste it at start mark
;; Is this just a problem with autocomplete not being fast enough?
;;* - This is probably a better solution: what if there are two autocomplete pools, one for function
;; or file-local symbols only which immediately prompts with dropdown (after a character)?
;; This could maybe work as some sort of delay hook: if I'm typing immediately show me file-local
;; source, but if I type and pause for N seconds enable the full tags source
;; Learn how to do custom mode for jumping back
;; - Expand-region does strange things with the region. Eg. C-s-' after moving cursor, expand region then type over (damn it; it went away after re-evaluating .emacs)
;; - Start using Abbrev more
;; - Create an explicit setup for jump to go back to last location (don't rely on marks; just store position)
;;*- Create an explicit setup for jump to go back to last location (don't rely on marks; just store position)
;; i.e. Reliable quick mark set and return for jumping to X from Y then going back to Y
;; This would be useful without jumping too. Basically just use register and one key to set/jump to (C- vs C-S)
;; - It seems like iy-goto-char will eventually trip me up in its temporary mode
;; - It seems like iy-goto-char will eventually trip me up in its temporary mode (so far it's fine)
;; - Seems like it would be cool to have a "copy to references" thing which would take marked and
;; put it in a references.org file or something for deep code reading dives (what about projects?)
;; - Command to close all dired buffers
;; - User-specific emacs configs (see http://whattheemacsd.com/ "Need different settings for different machines")
;; - Organize this file (org mode supported via outshine.el?)
;; - Make it so mark is cleared if arrow key away
;; - 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
;;*- IMPORTANT Codesearch ignore autogenerated files (maybe during building index?)
;;
;; Criticism improvements:
;; - [DONE] Select word at point
;; - [DONE] Reopen closed file
;; - [DONE-ish] Get find references working
;; - [DONE] Autorevert if no modifications (do tell me in modeline that this happened)
;; - [DONE] Faster/better Ag
;; Eventually make tags-search and tags-loop-continue async and list results in a buffer
;; - Faster browse symbols (first, figure out where most symbols come from and eliminate; then separate projects?)
;; Separate lists by first letter for x26 speedup? (kindof defeats purpose if not knowing first letter)
;; Copy swiper-all requiring multiple letters? (this doesn't seem to help too much)
;; - Faster/better Ag
;; - Swiper is too damn slow
;; Emacs Notes
@ -185,19 +196,37 @@
(defun macoy-kill-transient-buffers ()
"Auto kill buffers which aren't important to let hang around. You shouldn't run this while using things which use these buffers!"
(interactive)
;; TODO: Come on Macoy, make this a loop
(if (get-buffer "*compilation*") (kill-buffer "*compilation*"))
(if (get-buffer "*xref*") (kill-buffer "*xref*"))
(if (get-buffer "*CTags-out*") (kill-buffer "*CTags-out*"))
(if (get-buffer "*ag search*") (kill-buffer "*ag search*"))
(if (get-buffer "*log-edit-files*") (kill-buffer "*log-edit-files*"))
(if (get-buffer "*svn output*") (kill-buffer "*svn output*"))
;; TODO: Make sure dependent things aren't running when this happens!
(if (get-buffer "*Ediff Registry*") (kill-buffer "*Ediff Registry*"))
(if (get-buffer "*Help*") (kill-buffer "*Help*"))
(if (get-buffer "*Completions*") (kill-buffer "*Completions*"))
(if (get-buffer "*Compile-Log*") (kill-buffer "*Compile-Log*"))
(if (get-buffer "*Codesearch-Index*") (kill-buffer "*Codesearch-Index*"))
;; TODO: Make sure dependent buffers aren't broken when this happens!
(setq macoy-buffers-to-kill (list
"*Backtrace*"
"*CTags-out*"
"*Calc Trail*"
"*Calculator*"
"*Codesearch*"
"*Codesearch-Index*"
"*Compile-Log*"
"*Completions*"
"*Diff*"
"*Ediff Registry*"
"*Gimme-checkout*"
"*Gimme-GetLatest*"
"*Help*"
"*Packages*"
"*ag search*"
"*compilation*"
"*log-edit-files*"
"*svn output*"
"*vc-change-log*"
"*vc-diff*"
"*xref*"
))
(mapcar
(lambda (buffer-to-kill)
(when (get-buffer buffer-to-kill)
(kill-buffer buffer-to-kill))
)
macoy-buffers-to-kill
)
)
;; Store recently closed files so we can easily reopen them
@ -422,7 +451,7 @@
(setq ag-arguments '("--smart-case" "--stats" "-G"
"(\\.txt|\\.org|\\.cpp|\\.c|\\.h|\\.inl|\\.html|\\.css|\\.lua|\\.js|\\.py|\\.cdm|\\.el)"
"--ignore" "AutoGen"))
(global-set-key (kbd "C-S-f") 'ag)
(global-set-key (kbd "C-M-f") 'ag)
;; Codesearch: Use a pregenerated index to search files. Requires Codesearch
(when (string-equal (user-login-name) "mmadson")
@ -438,18 +467,34 @@
(defun macoy-codesearch-index-src ()
(interactive)
(start-process "CodesearchIndex" "*Codesearch-Index*" codesearch-cindex-exe codesearch-dir-to-index)
(message "Running Codesearch index on %s" codesearch-dir-to-index)
(let ((codesearch-proc (start-process "CodesearchIndex" "*Codesearch-Index*" codesearch-cindex-exe codesearch-dir-to-index)))
(set-process-sentinel codesearch-proc
(lambda (codesearch-proc _string)
(message "Codesearch finished building index")))
)
)
;; Refer to ag.el for customization
(define-compilation-mode macoy-codesearch-mode "Codesearch"
"Codesearch results compilation mode"
)
(defun macoy-codesearch-search (pattern)
(interactive
(list
(read-string "Pattern: " (thing-at-point 'symbol))))
;; Just use the compile command so we have nice clickable links
;; Refer to ag.el or codesearch.el for other ways to do this. I did this way because it's simple
(compile (format "%s -n %s" codesearch-csearch-exe pattern))
(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)
(compilation-start (format "%s -n -i %s" codesearch-csearch-exe (regexp-quote pattern))
#'macoy-codesearch-mode
`(lambda (mode-name) , "*Codesearch*")
)
)
(global-set-key (kbd "C-S-f") 'macoy-codesearch-search)
;; Simpleclip makes system clipboard and emacs kill ring separate
;; This is sane copy paste behavior
(require 'simpleclip)
@ -1098,10 +1143,10 @@
(global-set-key (kbd "M-R") 'copy-to-register)
;; Move to beginning/end of function
(global-set-key (kbd "M-<up>") 'c-beginning-of-defun)
(global-set-key (kbd "M-<down>") 'c-end-of-defun)
(global-set-key (kbd "C-<prior>") 'c-beginning-of-defun)
(global-set-key (kbd "C-<next>") 'c-end-of-defun)
(global-set-key (kbd "M-<up>") 'beginning-of-defun)
(global-set-key (kbd "M-<down>") 'end-of-defun)
(global-set-key (kbd "C-<prior>") 'beginning-of-defun)
(global-set-key (kbd "C-<next>") 'end-of-defun)
(require 'expand-region)
;; I don't like it creating temporary binds (what if I want to type those symbols?)

Loading…
Cancel
Save