Difference between revisions of "User:Timothee Flutre/Notebook/Postdoc/2012/07/25"

From OpenWetWare
Jump to: navigation, search
(About Emacs: add emacs -nw)
(About Emacs: add official tutorial)
 
(21 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
|-
 
|-
 
|style="background-color: #EEE"|[[Image:owwnotebook_icon.png|128px]]<span style="font-size:22px;"> Project name</span>
 
|style="background-color: #EEE"|[[Image:owwnotebook_icon.png|128px]]<span style="font-size:22px;"> Project name</span>
|style="background-color: #F2F2F2" align="center"|<html><img src="/images/9/94/Report.png" border="0" /></html> [[{{#sub:{{FULLPAGENAME}}|0|-11}}|Main project page]]<br />{{#if:{{#lnpreventry:{{FULLPAGENAME}}}}|<html><img src="/images/c/c3/Resultset_previous.png" border="0" /></html>[[{{#lnpreventry:{{FULLPAGENAME}}}}{{!}}Previous entry]]<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html>}}{{#if:{{#lnnextentry:{{FULLPAGENAME}}}}|[[{{#lnnextentry:{{FULLPAGENAME}}}}{{!}}Next entry]]<html><img src="/images/5/5c/Resultset_next.png" border="0" /></html>}}
+
|style="background-color: #F2F2F2" align="center"|[[File:Report.png|frameless|link={{#sub:{{FULLPAGENAME}}|0|-11}}]][[{{#sub:{{FULLPAGENAME}}|0|-11}}|Main project page]]<br />{{#if:{{#lnpreventry:{{FULLPAGENAME}}}}|[[File:Resultset_previous.png|frameless|link={{#lnpreventry:{{FULLPAGENAME}}}}]][[{{#lnpreventry:{{FULLPAGENAME}}}}{{!}}Previous entry]]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}{{#if:{{#lnnextentry:{{FULLPAGENAME}}}}|[[{{#lnnextentry:{{FULLPAGENAME}}}}{{!}}Next entry]][[File:Resultset_next.png|frameless|link={{#lnnextentry:{{FULLPAGENAME}}}}]]}}
 
|-
 
|-
 
| colspan="2"|
 
| colspan="2"|
Line 8: Line 8:
 
==About Emacs==
 
==About Emacs==
  
* '''Motivation''': when analyzing data for any research project, it's essential to know well a good text editor. Indeed, it's very efficient to be able to program in several languages (eg. Python, C/C++, R), interact with the shell like in a terminal, manipulate data and plot exploratory analyzes in R, ''all this within the same editor''! One such editor is [http://en.wikipedia.org/wiki/Emacs Emacs], and is available on Linux, Mac OS and Windows.
+
* '''Motivation''': when analyzing data for any research project, it's essential to know well a good text editor. Indeed, it's very efficient to be able to program in several languages (eg. Python, C/C++, R), interact with the shell like in a terminal, manipulate data and plot exploratory analyzes in R, ''all this within the same editor''! One such editor is [http://en.wikipedia.org/wiki/Emacs Emacs], and is available on Linux, Mac OS and Windows. For Mac OS X users, I recommend [http://vgoulet.act.ulaval.ca/en/emacs/mac/ this distribution].
  
* '''Configuration''': my own file <nowiki>.emacs</nowiki>
+
* '''Documentation''':
 
+
** official [https://www.gnu.org/software/emacs/manual/html_node/emacs/index.html manual] ([https://www.gnu.org/software/emacs/manual/html_node/eintr/index.html intro] to Emacs Lisp)
<nowiki>
+
** official [https://www.gnu.org/software/emacs/tour/ tour]
;; .emacs
+
** official tutorial: <code>C-h t</code>
 
+
** [http://www.tuteurs.ens.fr/unix/editeurs/emacs.html tutorial] (in French)
(custom-set-variables
+
** [http://www.emacswiki.org/ wiki] (with many tips)
  ;; custom-set-variables was added by Custom.
+
** [https://github.com/vikasrawal/orgpaper/blob/master/orgpapers.org org tutorial]
  ;; If you edit it by hand, you could mess it up, so be careful.
+
** [https://github.com/emacsmirror/p code] (mirrors packages)
  ;; Your init file should contain only one such instance.
+
** [http://xkcd.com/378/ cartoon]
  ;; If there is more than one, they won't work right.
+
** [https://ebooks-it.org/1565922611-ebook.htm guide] on how to write GNU Emacs extensions
'(column-number-mode t) ;; in the mode line
 
'(size-indication-mode t) ;; in the mode line
 
'(display-time-mode 1) ;; in the mode line
 
'(display-time-day-and-date t) ;; in the mode line
 
'(display-time-24hr-format t) ;; in the mode line
 
'(case-fold-search t)
 
'(current-language-environment "UTF-8")
 
'(default-input-method "rfc1345")
 
'(global-font-lock-mode t nil (font-lock))
 
'(show-paren-mode t))
 
(custom-set-faces
 
  ;; custom-set-faces was added by Custom.
 
  ;; If you edit it by hand, you could mess it up, so be careful.
 
  ;; Your init file should contain only one such instance.
 
  ;; If there is more than one, they won't work right.
 
)
 
 
 
(setq inhibit-startup-message t)
 
 
 
(add-to-list 'load-path "~/.emacs.d/")
 
 
 
(setq latex-run-command "pdflatex")
 
 
 
;; config for C/C++ code
 
(setq c-default-style "bsd"
 
          c-basic-offset 2
 
          tab-width 2
 
          indent-tabs-mode t)
 
 
 
;;--------------------------------------------------------------------
 
 
 
;; START config Auto-Complete
 
(require 'auto-complete-config)
 
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
 
(ac-config-default)
 
;; END config Auto-Complete
 
 
 
;;--------------------------------------------------------------------
 
 
 
;; START config ESS
 
(load "~/src_ext_nb/ESS/ess-12.04-4/lisp/ess-site")
 
 
 
;; tips from http://emacswiki.org/emacs/EmacsSpeaksStatistics
 
(setq ess-eval-visibly-p nil) ;otherwise C-c C-r (eval region) takes forever
 
(setq ess-ask-for-ess-directory nil) ;otherwise you are prompted each time you start an interactive R session
 
;; END config ESS
 
 
 
;;--------------------------------------------------------------------
 
 
 
;; START config AUCTeX
 
(load "/home/tflutre/src/LATEX_PKGS/AUCTEX/auctex.el" nil t t)
 
(load "/home/tflutre/src/LATEX_PKGS/AUCTEX/preview-latex.el" nil t t)
 
(add-to-list 'load-path "/home/tflutre/src/LATEX_PKGS/AUCTEX")
 
(setq TeX-auto-save t)
 
(setq TeX-parse-self t)
 
(setq-default TeX-master nil)
 
(setq TeX-save-query nil)
 
(setq TeX-PDF-mode t) ;; to have a pdf output for all LaTeX documents
 
;; END config AUCTeX
 
 
 
;;--------------------------------------------------------------------
 
 
 
;; START config org-mode
 
(setq load-path (cons "/home/tflutre/src/ORG-MODE/org-7.8.03/lisp" load-path))
 
(setq load-path (cons "/home/tflutre/src/ORG-MODE/org-7.8.03/contrib/lisp" load-path))
 
(require 'org-install)
 
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
 
(global-set-key "\C-cl" 'org-store-link)
 
(global-set-key "\C-cc" 'org-capture)
 
(global-set-key "\C-ca" 'org-agenda)
 
(global-set-key "\C-cb" 'org-iswitchb)
 
(org-babel-do-load-languages
 
'org-babel-load-languages
 
'((R . t)
 
  (sh . t)
 
  (python . t)
 
  ))
 
(setq org-confirm-babel-evaluate nil)
 
(require 'org-latex)
 
(add-to-list 'org-export-latex-packages-alist '("" "listings"))
 
(setq org-export-latex-listings t)
 
(setq org-export-latex-listings-options
 
      '(("breaklines")))
 
(setq org-log-done 'time)
 
;; END config org-mode
 
</nowiki>
 
  
 
* '''Important packages''':
 
* '''Important packages''':
 +
** [http://orgmode.org/) org-mode]
 +
** [http://cx4a.org/software/auto-complete/ Auto-Complete]
 
** [http://ess.r-project.org/ ESS]
 
** [http://ess.r-project.org/ ESS]
** [http://cx4a.org/software/auto-complete/ Auto-Complete]
 
** [http://orgmode.org/) org-mode]
 
 
** [http://www.gnu.org/software/auctex/ AUCTeX]
 
** [http://www.gnu.org/software/auctex/ AUCTeX]
 +
 +
* '''Configuration''': my own file <nowiki>~/.emacs</nowiki> (versioned [https://github.com/timflutre/perso/blob/master/emacs here]):
  
 
* '''Tips''':
 
* '''Tips''':
** from the office computer, log interactively to a cluster node, launch <code>emacs --daemon</code> and keep the terminal open indefinitely; then access this session from any computer, e.g. a laptop, with <code>emacsclient -t</code>
+
** from the office computer (desktop), log interactively to a cluster node, launch <code>emacs --daemon</code> and keep the terminal open indefinitely; then access this session from any computer, e.g. a laptop, with <code>emacsclient -t</code>; and close it when needed via <code>emacsclient -e "(kill-emacs)"</code>
 
** especially useful with [http://en.wikipedia.org/wiki/PuTTY PuTTY] on Windows, launch emacs so that its window is the terminal itself, via <code>emacs -nw</code>
 
** especially useful with [http://en.wikipedia.org/wiki/PuTTY PuTTY] on Windows, launch emacs so that its window is the terminal itself, via <code>emacs -nw</code>
 +
** when updating org-mode, one may have to first comment all org-related lines in ~/.emacs, remove the dir ~/.emacs.d/elpa/org-*, re-open Emacs with option -Q, install the latest version of org-mode, close Emacs and re-open it without -Q, uncomment all org-related lines in ~/.emacs
 +
 +
* '''Emacs Lisp''': [http://www.gnu.org/software/emacs/manual/html_node/eintr/ intro]
 +
** see the content of a variable, <code>C-h v</code>, the enter the name of the variable, say <code>load-path</code>
 +
** go to the *scratch* buffer
 +
** write <code>(+ 2 2)</code>
 +
** put the cursor after the last parenthesis, and enter <code>C-x C-e</code>
 +
** one should see <code>4</code> in the mini-buffer
 +
** do the same with <code>(concat "abc" "def")</code>
 +
** here is an example of a [https://www.gnu.org/software/emacs/manual/html_node/eintr/Writing-Defuns.html#Writing-Defuns function] (interactive in this case)
 +
 +
(defun f (x y)
 +
  "add"
 +
  (interactive "nx=\nny=")
 +
  (message "%i" (+ x y))
 +
  )
  
 
<!-- ##### DO NOT edit below this line unless you know what you are doing. ##### -->
 
<!-- ##### DO NOT edit below this line unless you know what you are doing. ##### -->

Latest revision as of 14:16, 4 November 2017

Owwnotebook icon.png Project name Report.pngMain project page
Resultset previous.pngPrevious entry      Next entryResultset next.png

About Emacs

  • Motivation: when analyzing data for any research project, it's essential to know well a good text editor. Indeed, it's very efficient to be able to program in several languages (eg. Python, C/C++, R), interact with the shell like in a terminal, manipulate data and plot exploratory analyzes in R, all this within the same editor! One such editor is Emacs, and is available on Linux, Mac OS and Windows. For Mac OS X users, I recommend this distribution.
  • Configuration: my own file ~/.emacs (versioned here):
  • Tips:
    • from the office computer (desktop), log interactively to a cluster node, launch emacs --daemon and keep the terminal open indefinitely; then access this session from any computer, e.g. a laptop, with emacsclient -t; and close it when needed via emacsclient -e "(kill-emacs)"
    • especially useful with PuTTY on Windows, launch emacs so that its window is the terminal itself, via emacs -nw
    • when updating org-mode, one may have to first comment all org-related lines in ~/.emacs, remove the dir ~/.emacs.d/elpa/org-*, re-open Emacs with option -Q, install the latest version of org-mode, close Emacs and re-open it without -Q, uncomment all org-related lines in ~/.emacs
  • Emacs Lisp: intro
    • see the content of a variable, C-h v, the enter the name of the variable, say load-path
    • go to the *scratch* buffer
    • write (+ 2 2)
    • put the cursor after the last parenthesis, and enter C-x C-e
    • one should see 4 in the mini-buffer
    • do the same with (concat "abc" "def")
    • here is an example of a function (interactive in this case)
(defun f (x y)
  "add"
  (interactive "nx=\nny=")
  (message "%i" (+ x y))
  )