Coder Social home page Coder Social logo

iqss.emacs's Introduction

title
Emacs for the rest of us

This is an Emacs configuration. There are many like it, but this one is mine. If you like it, make it yours! It provides lots of functionality while keeping things light and fast. It tries to tames Emacs, making it behave more like other applications you use.

Project goals and philosophy

The main goal of this project is to provide an Emacs configuration that works more or less they way you would expect an editor or IDE to work in the second decade of the twenty-first century, without losing the things that make Emacs special. The included packages were selected with social scientists in mind (e.g., it includes support for R, Stata, Python, Markdown, and LaTeX).

The overarching philosophy is pragmatism; we're trying to make Emacs as useful as possible, and to reduce the time needed to start using Emacs productively.

Feature highlights

Highlights of this Emacs configuration:

  • Literate programming configuration for running R, python, or other programming languages inside markdown or org-mode files.
  • Consistent and familiar code evaluation using C-ret (that's Control + Return).
  • Consistent indentation and folding using the tab key.
  • Consistent completion using <tab>.
  • Support for LaTeX and other markup languages.
  • Powerful and simple search-based tools for finding commands, files and buffers, inserting citations etc.
  • More standard select/copy/paste keys and right-click behavior makes it more familiar to those new to Emacs.
  • Multiple cursors, as in Sublime and VScode
  • Convenient window management.

Installation

If you previously had another version of Emacs installed it is a good idea to move your ~/.emacs.d configuration folder to a backup location before installing this Emacs configuration. If you do not yet have Emacs, installers available for Mac OSX and Windows.

Once Emacs is installed, install this configuration by copying the files from https://github.com/iqss/IQSS.emacs to a folder named .emacs.d in your home directory. For example, you can run git clone https://github.com/IQSS/IQSS.emacs.git ~/.emacs.d, or you can download the .zip archive from https://github.com/IQSS/IQSS.emacs/archive/master.zip, extract it, and move the files to ~/.emacs.d.

First run

Note that after installing this configuration emacs will be slow to start up the first time. This is due to package installation; just be patient and wait for it to finish--subsequent start-ups will be much faster.

Getting started

If you have never used Emacs before many things will work as you expect. This is especially true on Mac OS X. If you use Windows, note that standard Windows shortcuts starting with control have been shifted to the windows key. For example, to copy use win-c rather than control-c, and to paste use win-v rather than control-c.

A few things may not work as you expect, in which case you will need to search the web or read the Emacs documentation to learn the Emacs way. You can launch a built-in tutorial by pressing =C-h t= (that's "Control+h, then t"), or read the getting started documentation at https://www.gnu.org/software/emacs/tour/. A cheat-sheet / survival guide is available at https://www.gnu.org/software/emacs/refcards/pdf/survival.pdf.

If you are an Emacs user, most things will mostly work as you expect, though you may wish to familiarize yourself with the alternative key bindings configured here. If you are an Emacs user and you find key bindings that don't work as they should please open an issue in the [[https://github.com/IQSS/IQSS.emacs][github repo]].

Keyboard shortcuts

This documentation mostly uses Emacs notation for keybindings, e.g., C means "the Control key", S means "the Shift key", and M means "the Meta (aka Alt) key". Note that on a Mac M means "the Option key". Refer to https://www.emacswiki.org/emacs/EmacsKeyNotation if you are not familiar with this notation.

The most important keyboard shortcut in Emacs is M-x (that's "hold down Alt and press x" Windows, and "hold down Option and press x" on Mac). M-x brings up a search-able list of all Emacs commands. In fact you could use this interface for everything and never bother learning any of the other keybindings listed below. For example, to open a file you could type M-x counsel-find-file <ret> instead of win-o. Nobody does this in practice, because win-o is easier. But if you can't remember the name of a keyboard shortcut don't worry: just type M-x and search for the command you need.

The second most important keyboard shortcut is C-g (that's "hold down control and press g"). If Emacs starts doing something you don't want it to, press C-g to cancel. If it doesn't work, press C-g again.

Other commonly used key bindings are listed in the following sections.

Standard shortcuts

On Mac OS X standard keyboard shortcuts should mostly work as expected.

On Windows, many common keyboard shortcuts start with the control key. This is a problem for Emacs, since many of it's most-used shortcuts conflict with the usual Windows meaning. For example, C-a means "select all" on Windows, but "go to the beginning of the line" in Emacs. The solution adopted here is to move standard Windows keybindings to the win key. The advantage is that we retain normal Emacs behavior (C-a has the Emacs meaning of "go to the beginnign of the line). The disadvantage is that you'll have to get used to pressing different keys (win-a instead of c-a to select all).

Multiple cursors

You can add multiple cursors by pressing C-c m and following the on-screen prompts. This feature is experimental; comments or suggestions welcome at https://github.com/IQSS/IQSS.emacs/issues. For more information about the Emacs multiple cursors implementation refer to https://github.com/magnars/multiple-cursors.el.

Window management

One of the things that makes Emacs different that most other applications is the way that it handles windows. Unlike most Integrated Development Environments, there is no fixed layout. Instead, windows are created and killed as needed. New Emacs uses sometimes try to get Emacs to stop messing with their window layout -- my approach is to just let Emacs do what it wants and the revert the layout using C-c left.

Key Description
C-x 2 Split horizontally
C-x 3 Split vertically
C-x 1 Remove splits
C-x S-<arrow> Move to other window
C-x S-0 Move to a window by number
C-c left Undo a window layout change
C-c right Redo a window layout change
C-c v Save window layout
C-c V Restore a saved window layout
C-c a Rotate window arrangements
C-c b Rotate buffers

Searching and Completion

Utilities have been configured to make it easy to search by file name as well as to search the contents of files. Some of this functionality works much better if certain system utilities are found. See this list of useful programs, especially everything (windows only) and the silver searcher or ripgrep.

Basic search/replace should work as you expect, except that again on Windows you should use the win key instead of the control key. For example, you can use win-f to search.

In addition, you can search for files in a directory by name or contents using the keys described in the table below.

Key Description Notes
win-f Find in file
C-c l Searches for files by name (think "locates")
C-c f (or C-c s) Searches file contents requires mlocate on linux, everything (http://www.voidtools.com/) on windows
<tab> Completion suggestions
win-S-v Paste from the clipboard history M-S-y also works for this
C-c r Search for a reference to insert You must set bibtex-completion-bibliography to your BibTeX files for this to work

REPL interaction

This should be easy, and hopefully it is!

Note that we use a heuristic to decide whether to install language support (e.g., for R or Scala etc.). If the corresponding program is in your PATH Emacs support will be installed. For example, if R is in your PATH the ESS package will be installed.

Aliases have been created for starting R, python, haskell, and terminals. For example, to start python just type M-x python <ret>.

To execute a line, region, or buffer from a script (R, python, bash) etc.) use the keybindings below.

Key Description Notes
C-RET Line/selection/expression evaluation Works for R, python, shell, and others
S-C-RET Buffer evaluation Evaluate the whole script

Interacting with external programs

Many of the Emacs features configured here are designed to make it easier to interact with external programs. For example, ESS makes it easy to interact with R, and AUCTEX makes it easy to interact with LaTeX. If you need help installing these programs, this short guide may help.

Customization

You can put any additional Emacs configuration in ~/.emacs.d/custom.el. This file is loaded last, so you always have the chance to override any settings you don't like. You can require additional packages by adding the to package-selected-packages. For example, putting (add-to-list 'package-selected-packages 'matlab-mode) in your custom.el file will ensure that the matlab-mode package is installed.

More information

For more information refer to the annotated configuration file.

iqss.emacs's People

Contributors

grszkthfr avatar istazahn avatar izahn avatar jyuenger avatar whorka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

iqss.emacs's Issues

unit tests

how about we eat our own dog food and create a set of unit tests that get run every time we are about to push a new version to git?

typo in README.md and custom.el

Hi,
thanks for providing such a nice .emacs.d.

I am completly new to emacs, there is one small typo in the customization section of the README.md, which gave me some headaches...

(add-to-list 'package-slected-packages 'matlab-mode) should be (add-to-list 'package-selected-packages 'matlab-mode)

The same sneaked somehow into the custom.el with ;; (add-to-list 'package-slected-packages 'ess) which should be ;; (add-to-list 'package-selected-packages 'ess).

Best Jonas

First run finishing with error

I had this error in first run

`
Warning (bytecomp): reference to free variable ‘mc/cycle’
Warning (bytecomp): the following functions are not known to be defined: mc/cursor-beg,
mc/cursor-end, return-from
Warning (bytecomp): ‘set-temporary-overlay-map’ is an obsolete function (as of 24.4); use ‘set-transient-map’ instead.
Warning (bytecomp): looking-back called with 1 argument, but requires 2-3
Warning (bytecomp): the following functions are not known to be defined:
sgml-get-context, sgml-skip-tag-forward
Warning (bytecomp): defcustom for ‘mc/mode-line’ fails to specify type [2 times]
Warning (bytecomp): defcustom for ‘query-replace-from-to-separator’ fails to specify containing group
Warning (bytecomp): assignment to free variable ‘vr--is-emacs24’
Warning (bytecomp): misplaced interactive spec: ‘(interactive (vr--interactive-get-args (quote vr--mode-regexp) (quote vr--calling-func-mc-mark)))’
Warning (bytecomp): reference to free variable ‘clm/log-command-exceptions*’
Warning (bytecomp): defgroup for ‘command-log’ fails to specify containing group
Warning (bytecomp): assignment to free variable ‘ido-enable-flex-matching’
Warning (bytecomp): assignment to free variable ‘apropos-do-all’
Warning (bytecomp): assignment to free variable ‘ediff-window-setup-function’
Warning (bytecomp): the function ‘html2text’ is not known to be defined.
Warning (bytecomp): reference to free variable ‘ecb-activated-window-configuration’
Warning (bytecomp): reference to free variable ‘path’
Warning (bytecomp): reference to free variable ‘path-method’
Warning (bytecomp): reference to free variable ‘tramp-methods’
Warning (bytecomp): reference to free variable ‘path-user’
Warning (bytecomp): reference to free variable ‘path-host’
Warning (bytecomp): reference to free variable ‘path-localname’
Warning (bytecomp): the following functions are not known to be defined: ecb-deactivate,
ecb-activate, tramp-tramp-file-p, with-parsed-tramp-file-name
Warning (bytecomp): ‘show-branches’ is an obsolete function (as of 25.1); use ‘outline-show-branches’ instead.
Warning (bytecomp): ‘show-all’ is an obsolete function (as of 25.1); use ‘outline-show-all’ instead.
Warning (bytecomp): ‘hide-sublevels’ is an obsolete function (as of 25.1); use ‘outline-hide-sublevels’ instead.
Warning (bytecomp): ‘show-entry’ is an obsolete function (as of 25.1); use ‘outline-show-entry’ instead.
Warning (bytecomp): ‘show-children’ is an obsolete function (as of 25.1); use ‘outline-show-children’ instead.
Warning (bytecomp): ‘show-subtree’ is an obsolete function (as of 25.1); use ‘outline-show-subtree’ instead.
Warning (bytecomp): ‘hide-subtree’ is an obsolete function (as of 25.1); use ‘outline-hide-subtree’ instead.
Warning (bytecomp): attempt to let-bind nonvariable ‘(lucr (msl--LUCR-filter-LaTeX-aliases lucr))’
Warning (bytecomp): assignment to free variable ‘company-math--unicode-prefix-regexp’
Warning (bytecomp): reference to free variable ‘company-math--unicode-prefix-regexp’ [2 times]
Warning (bytecomp): the function ‘assoc-delete-all’ is not known to be defined.
Warning (bytecomp): ‘eieio-object-name-string’ is an obsolete function (as of 25.1); use ‘eieio-named’ instead. [2 times]
Warning (bytecomp): looking-back called with 1 argument, but requires 2-3
Error (bytecomp): Cannot open load file: No such file or directory, cider
Error (bytecomp): Cannot open load file: No such file or directory, elm-mode
Error (bytecomp): Cannot open load file: No such file or directory, erlang
Error (bytecomp): Cannot open load file: No such file or directory, geiser-mode
Error (bytecomp): Cannot open load file: No such file or directory, hy-mode
Error (bytecomp): Cannot open load file: No such file or directory, elixir-mode
Error (bytecomp): Cannot open load file: No such file or directory, js-comint
Error (bytecomp): Cannot open load file: No such file or directory, lua-mode
Error (bytecomp): Cannot open load file: No such file or directory, tuareg
Warning (bytecomp): the function ‘prolog-consult-region’ is not known to be defined.
Warning (bytecomp): ‘python-shell-get-or-create-process’ is an obsolete function (as of 25.1); Instead call ‘python-shell-get-process’ and create one if returns nil.
Warning (bytecomp): ‘python-shell-parse-command’ is an obsolete function (as of 25.1); use ‘python-shell-calculate-command’ instead.
Error (bytecomp): Cannot open load file: No such file or directory, racket-mode
Error (bytecomp): Cannot open load file: No such file or directory, inf-ruby
Error (bytecomp): Cannot open load file: No such file or directory, slime
Error (bytecomp): Cannot open load file: No such file or directory, sly
Error (bytecomp): Cannot open load file: No such file or directory, sml-mode
Warning (bytecomp): Unused lexical variable ‘name-repl-buffer’
Warning (bytecomp): Unused lexical variable ‘name-script-buffer’
Warning (bytecomp): defcustom for ‘dumb-jump-ivy-jump-to-selected-function’ fails to specify type [2 times]
Warning (bytecomp): ‘find-tag-marker-ring’ is an obsolete variable (as of 25.1); use ‘xref-push-marker-stack’ or ‘xref-pop-marker-stack’ instead.
Warning (bytecomp): the function ‘helm-build-sync-source’ is not known to be defined.
Warning (bytecomp): ‘flycheck-disable-checker’ is for interactive use only; Directly set ‘flycheck-disabled-checkers’ instead
Warning (bytecomp): the following functions are not known to be defined: event-point,
delete-extent, make-extent, set-extent-property,
balloon-help-minor-mode
Warning (bytecomp): defcustom for ‘untitled-new-buffer-default-name’ fails to specify type [2 times]

In poetry-new:
poetry.el:403:11:Warning: reference to free variable ‘poetry-tracking-mode’

In poetry-venv-workon:
poetry.el:473:9:Warning: reference to free variable ‘poetry-tracking-mode’
poetry.el:479:1:Warning: Unused lexical variable ‘venv’

In poetry-venv-deactivate:
poetry.el:482:9:Warning: reference to free variable ‘poetry-tracking-mode’
poetry.el:546:11:Warning: Unused lexical argument ‘args’
poetry.el:546:11:Warning: Unused lexical argument ‘args’
poetry.el:671:1:Warning: Unused lexical argument ‘len’
`

emacs --debug-init report

Debugger entered--Lisp error: (file-error "https://elpa.gnu.org/packages/archiv$ signal(file-error ("https://elpa.gnu.org/packages/archive-contents" "Bad Requ$ package--download-one-archive(("gnu" . "https://elpa.gnu.org/packages/") "arc$ package--download-and-read-archives(nil) package-refresh-contents() (if (cl-every 'package-installed-p package-selected-packages) nil (message "M$ eval-buffer(#<buffer *load*> nil "/home/pi/.emacs.d/init.el" nil t) ; Readi$ load-with-code-conversion("/home/pi/.emacs.d/init.el" "/home/pi/.emacs.d/init$ load("/home/pi/.emacs.d/init" t t) #f(compiled-function () #<bytecode 0xaa6bf>)()

Raspbian Buster. emacs --version show:
GNU Emacs 26.1 Copyright (C) 2018 Free Software Foundation, Inc.

But all packages are updated. Is there any newer version of Emacs for Raspbian?

This is really nice and elegant. The repositories should be general, win-win is not recognised on mac

This is really nice much better than bigger distributions, lean, and powerful. A couple of glitches on my man
win -win is not available and respositories should be changed to

package-archives '(("gnu" . "http://elpa.gnu.org/packages/")

                ("org" . "http://orgmode.org/elpa/")

                ("melpa" . "http://melpa.org/packages/")

                ("melpa-stable" . "http://stable.melpa.org/packages/"))

package-archive-priorities '(("melpa-stable" . 1)))

Yes-or-no emacs lisp bypass

Hi Ista,

I was wondering if you could patch such that the (yes-no) functions are no longer used in init.el. If you don't have time, I could submit this patch for your approval.

I want to bake this into a docker image and use emacs --script to pre-compile all the functions, but, it still asks for interactive acceptance.

Do you have a better way I might go about this other than patching?

Best,
Evan

emacs dies on loading

after asking about anonconda-mode, and I answer Y, the load script apparently exits and it dies. custom fonts etc are not loaded. can you fix?

Update for emacs 28

Emacs 28 was released today with a huge set of changes and improvements: https://github.com/emacs-mirror/emacs/blob/emacs-28.1/etc/NEWS

This is good news because it means we can remove some things that are now better supported by default. It also means that we have some work to do to remove obsolete packages and settings from our setup.

TODO:

make 2nd compile request abort 1st

c-c, c-a compiles. if while waiting for it to compile you see something else to change, change it, save, and hit c-c, c-a again, bad stuff happens. a better behavior, after hitting c-c, c-a whenever compiling is happening, would be for it to abort the first compile automatically (without asking) and to restart it.

latex mode

i have a file with .tex extension that, in case it is relevant, begins with the line:
\subsection*{}

when I load this in emacs, it doesn't recognize it as latex and doesn't turn on latex-mode. Shouldn't it turn on latex-mode for any .tex file? Can we put that in effect?

thanks

it thinks tex engine is not set, but it is

many times when latexing bombs out, such as omitting an includegraphics file, and i fix it, and rerun again, the same file says:
(1/4) TeX engine not set, how should this document be typeset?:

even tho this has been set already on the bottom of the file.

latex engine, read only

another issue with latex engine: if you do c-f, c-f and view a file (i.e., in read only mode), it asks you which engine you want. it shouldn’t ask at that point. it is also hard to get out of it.

ctrl + ↓ has stopped working

Gary was trying to use the ctrl + ↓ keyboard shortcut to scroll without moving the text cursor. ctrl + ↑ works as intended to scroll, but he's lost the ctrl + ↓ functionality. He is having the issue on multiple laptops. It appears Apple removed or started overriding this shortcut at some point.

My colleague Corey who is working with Gary on this found this:
You can add these lines to your Emacs configuration file, which is usually ~/.emacs or ~/.emacs.d/init.el. After adding these lines, restart Emacs or evaluate the changes with M-x eval-buffer. Then, you should be able to use Ctrl + Up and Ctrl + Down to scroll through text without moving the cursor:
;; Map Ctrl + Up and Ctrl + Down to scroll without moving cursor
(global-set-key (kbd "C-") 'scroll-down-line)
(global-set-key (kbd "C-") 'scroll-up-line)

However, Gary told him he shouldn't edit init.el since it might mess with your custom settings. Corey tried adding the above commands in ~/.emacs/custom, but that didn't work.

Rmarkdown

Could we extend support to rmarkdown? (rmarkdown runs r and produces markdown code which produces latex which runs pdflatex to produce pdfs.) Ideally, it should use the same emacs commands as we use for editing latex (ctrl-c,a to compile and view etc). Gary

Literal vs regex search

Since we usually don't use regular expressions in searches, we should bind isearch-forward to C-s and relegate isearch-forward-regex to C-S-s.

IQSS.emacs dies on the new macs

Can we update this for the new Apple silicon? Here's what I get trying to install on a brand new machine:

Compiling internal form(s) at Wed Feb 2 11:35:14 2022
Warning (bytecomp): assignment to free variable ‘gud-pdb-command-name’ [2 times]
Warning (bytecomp): ‘python-shell-virtualenv-path’ is an obsolete variable (as of 25.1); use ‘python-shell-virtualenv-root’ instead.
Warning (bytecomp): assignment to free variable ‘conda-project-env-path’
Warning (bytecomp): reference to free variable ‘prev-env’
Warning (bytecomp): assignment to free variable ‘eshell-modify-global-environment’
Warning (bytecomp): ‘python-shell-virtualenv-path’ is an obsolete variable (as of 25.1); use ‘python-shell-virtualenv-root’ instead. [2 times]
Warning (bytecomp): variable ‘_’ not left unused
Error (bytecomp): Cannot open load file: No such file or directory, ess-mode
Warning (bytecomp): ‘dummy’ is an obsolete variable (as of 25.1); use 'dummy instead [3 times]

ESS toolbar

I like to have my toolbar enabled. But even with the global toolbar option turned on, using the IQSS init file, I don't get the toolbar "buttons" for ESS to show up. (LaTeX, on the other hand, does.) can you point me to the setting that's causing this behavior in this file?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.