Skip to content

SylvainRoy/emacs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Emacs config

My emacs config.

It most provide a config which works well for python/elpy and poetry (read below). Also in there: multiple-cursors, perl-like regexp, ido and a few elisp shoartcuts I like.

This repository should be saved as .emacs.d in the $HOME directory.

It is in part inspired by [https://gist.github.com/widdowquinn/987164746810f4e8b88402628b387d39]

Keys

Global Keys

These bindings are coming from vanilla emacs. I just never remember them.

  • C-x z: repeat previous command
  • C-q C-j: insert new line in mini buffer
  • M-3: Equivalent C-u 3
  • C-h f piece-of-fun-name: to get function documentation
  • C-h k : to get teh function called by a key binding

Magit

  • C-x g: Display magit dashboard, then from there:
    • g: refresh
    • p/n: previous/next line/section
    • TAB: expand/collapse region
    • s/u: stage/unstage a file
    • c: commit (then c, then C-c C-c)
    • P: push (then p)
    • q: quit
    • b: checkout (then b)
  • C-x M-g: Get transient action from any file

Custom keys

Those ones are specific to this config.

  • M-o: next buffer
  • M-S-o: previous buffer
  • C-S-c C-S-c: multiple cursors on lines of block
  • C-,: multiple cursors on next line
  • C-<: multiple cursors on previous line
  • C-c C-,: multiple cursors on all similar lines
  • M-j: join lines
  • C-S-j: Eval elisp expression and replace by result
  • C-S-o: sticky buffer
  • C-x p: Find file & line number at point ang go there

Local config

A file called '.dir_locals.el' can be put in a folder to define a local config. This is very useful with elpy/pyvenv and can be used that way:

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((python-mode . ((pyvenv-workon . "py37"))))

This can also be plugged with poetry to retrieve the venv:

((python-mode
(eval pyvenv-activate
      (shell-command-to-string "poetry env info --path"))))

Useful pieces of code

Link a command to key binding:

(global-set-key (kbd "C-c C-c") 'compile)

Call an external script on a region and use output to replace it:

(defun do-something-region (startPos endPos)
  "Do some text processing on region.
This command calls the external script “wc”."
(interactive "r")
  (let (scriptName)
(setq scriptName "/usr/bin/wc") ; full path to your script
(shell-command-on-region startPos endPos scriptName nil t nil t)
))

Template of interactive function:

(defun test ()
  "my super fun"
  (interactive)
  (message "Here is the word at point: %s" (thing-at-point 'word))
  (end-of-thing 'word)
  (right-char))

Misc stuffMove to a given char:

(goto-char (point-min))

(while (search-forward "myStr1" nil t)

(defun change-title ()
  "change underline by surrounding =="
  (interactive)
  (kill-whole-line)
  (line-move -1)
  (beginning-of-line)
  (insert "== ")
  (end-of-line)
  (insert " =="))

(find-file-at-point)

About

My emacs config

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published