This post covers the following sections from my init.

  • Finding Files

  • Ediff


Emacs is old school. You're either new to it - which means you wouldn't be here unless it was your type of thing - or you know what you're looking for. In either case, go to the side bar of this page and click on the 'Emacs' tag. Then read the posts y date from oldest to newest.

In the last emacs post I covered lines 2004 - 2188. This post covers lines 2188 - 2379. I include the lines for anyone that wants to patch together the entire init from start to finish. The lines won't always match up because I take stuff out when I'm in the init.

Finding Files

First the diff and Ediff code is on hold. Diff and Ediff in emacs are great packages, a lot of people however enjoy newer programs for managing changes in files, especially when working with git revisions. I use a program called Beyond Compare with git and Diff and Ediff with most files. I've yet to put my diff/ediff system into a hydra though. So that comes later.

query-replace-regexp is just like C-f in your browser. You need the code below to do that with emacs. Anzu shows the number of matches in a give region. Ag is the Silver Searcher executable. It's a linux program so you have to find a version compiled just for windows, which you can do on the net, or with the version I referenced in earlier posts. You can of course use other search utilities in your hydra. In the Ag case you set the path to the ag-executable-p variable you set earlier. Helm-ag enables use of the helm interface to access the ag results.

;find and replace expressions in an emacs buffer
(global-set-key (kbd "M-&") 'query-replace-regexp)
;show number of matches
(use-package anzu
(global-anzu-mode +1)
(global-set-key [remap query-replace] 'anzu-query-replace)
(global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp)
(after-init . global-anzu-mode)
);end anzu

;find expressions in files in directories using ag
(use-package ag
:commands (ag-files ag-regexp ag-project ag-project-files ag-project-regexp)
(setq ag-executable ag-executable-p)
;(next-error-follow-minor-mode t)
;(automatically-display-search-results-at-point t)
(setq ag-highligh-search t)
(setq ag-reuse-buffers t)
(setq ag-reuse-window t)
;("M-s a" . ag-project)
);end ag
;use helm to activate ag with extra functionality
(use-package helm-ag
:commands (helm-ag helm-ag-this-file helm-do-ag helm-ag-project-root help-ag-buffers)
 '(helm-follow-mode-persistent t))
helm-ag-base-command         "rg --no-heading --smart-case"
helm-ag-fuzzy-match          t
;helm-ag-use-grep-ignore-list t
;helm-ag-use-agignore         t
);end helm-ag-init
:bind (:map helm-ag-map
("C-c o" . 'helm-ag-other-window-action)
("C-c >" . 'helm-ag-next-file)
("C-c >" . 'helm-ag-previous-file)
);end helm ag map
);end helm-ag

Here is the search Hydra

;find files hydra
(defvar find-files-title (with-octicon "search" "Search Files And Text With The Silver Searcher"))
;generate hydra
(pretty-hydra-define Search-Files (:title find-files-title :quit-key "q" :color teal )
("Basic Searches"
   (("a" ag "Search With Ag")
    ("m" helm-ag "Search With Helm Prefix")
    ("b" ag-kill-buffers "Delete Ag Buffers")
    ("o" ag-kill-other-buffers "Delete Other Ag Buffers")
);end basic
"More Specific Searches"
    ("f" ag-file "Text and File Specific Search Ag" )
    ("r" ag-regexp "Regular Expression Ag Search")
    ("t" helm-ag-this-file "Search Open File With Helm" )
    ("s" helm-ag-buffers "Search Buffers With Helm")
);end specific
"Project Searches"
    ("p" ag-project "Search Text In Projects" )
    ("R" ag-project-regexp "Search Regular Expresions In Projects")
    ("P" helm-ag-project-root "Search Project With Helm")
    ("h" hydra-helm/body "Return To Helm" :color blue )
    ("<SPC>" nil "Quit" :color blue )
);end project
);end hydra body
);end pretty-hydra-find-files
(bind-key "<C-m> s" 'Search-Files/body)

Emacs poseidon configuration code search hydra

Ido Mode

Ido mode is an alternative to helm. It structures searches in the minibuffer (whereas Helm enlarges greatly the mini-buffer and includes utilities.) With Helm my Ido-mode use drops off, but I include shortcuts to use it anyway. I enjoyed always use of Ido, only helm works for me a little bit better.

;ido mode and supporting
(use-package flx-ido
(require 'flx-ido)
(ido-mode 1)
;(ido-everywhere 1)
(flx-ido-mode 1)
;~ tilda to go to home directory
(defun my/ido-go-straight-home ()
   ((looking-back "~/") (insert "projects/"))
   ((looking-back "/") (insert "~/"))
   (:else (call-interactively 'self-insert-command))))
(defun recentf-ido-find-file ()
"Find a recent file using Ido."
(let ((file (ido-completing-read "Choose recent file: " recentf-list nil t)))
(when file
(find-file file))))
("C-x C-i" . ido-imenu)
("C-x M-f" . ido-find-file-other-window)
("C-x F" .  recentf-ido-find-file)
("C-x C-b" . ibuffer)
(:map ido-file-completion-map
(("C-~"  . my/ido-go-straight-home)
("C-w" . ido-delete-backward-updir)
("C-x C-w" . ido-copy-current-file-name)
("~" . (lambda () (interactive) (if
         (looking-back "/")
         (insert "~/")
         (call-interactively 'self-insert-command))))))
; turning off ido faces and on flex matching faces
(setq ido-enable-flex-matching t)
(setq ido-use-faces nil)
(setq ido-enable-prefix nil
      ido-enable-flex-matching t
      ido-case-fold nil
      ido-auto-merge-work-directories-length -1
      ido-create-new-buffer 'always
      ido-use-filename-at-point nil
      ido-max-prospects 10)
(setq flx-ido-use-faces t)
;; Always rescan buffer for imenu
(set-default 'imenu-auto-rescan t)
(global-unset-key (kbd "C-x TAB"))
);use package flx-ido
(use-package flx-isearch )
(use-package ido-at-point)
(use-package ido-ubiquitous)
(use-package ido-vertical-mode
(ido-vertical-mode t)
;; C-n/p is more intuitive in vertical layout
(setq ido-vertical-define-keys 'C-n-C-p-up-down-left-right)
);end use package
;; Fix ido-ubiquitous for newer packages
;(defmacro ido-ubiquitous-use-new-completing-read (cmd package)
;   `(eval-after-load ,package
;     '(defadvice ,cmd (around ido-ubiquitous-new activate)
;        (let ((ido-ubiquitous-enable-compatibility nil))
;          ad-do-it))))
;; Ido at point (C-,)
(require 'ido-at-point)
;; Use ido everywhere
;(require 'ido-ubiquitus)
;(ido-ubiquitous-mode 1)
;(ido-ubiquitous-use-new-completing-read webjump 'webjump)
;(ido-ubiquitous-use-new-completing-read yas-expand 'yasnippet)
;(ido-ubiquitous-use-new-completing-read yas-visit-snippet-file 'yasnippet)

As mentioned earlier, Ediff and Diff code isn't finalized yet (it's commented out in this part of the init).

That’s all for now…