Emacs, a performant IDE for Perl Tutorial for YAPC.:EU:::2009, Lisbon [email_address] Département Office
Overview <ul><li>Intended audience </li></ul><ul><ul><li>Emacs newcomers </li></ul></ul><ul><ul><li>[ seasoned Emacs users...
What is Emacs ? <ul><li>&quot;Emacs is the extensible, customizable, self-documenting real-time display editor&quot;.  </l...
Emacs history <ul><li>early 1970s : initial work on PDP computers (MIT Labs) </li></ul><ul><li>1976 : first release </li><...
Emacs main concepts <ul><li>buffer  : basic editing unit (text being edited). Can be bound to various contents like : </li...
Other concepts <ul><li>region  : portion of buffer between  mark  and  point </li></ul><ul><li>rectangle  : rectangular ar...
User input <ul><li>Input events </li></ul><ul><ul><li>character events </li></ul></ul><ul><ul><li>modifiers : <CTRL>, <ALT...
Entering commands/args in minibuffer <ul><li>Auto-completion </li></ul><ul><li>Default argument </li></ul><ul><li>Editing ...
Modes may implement … <ul><li>additional commands </li></ul><ul><li>local implementation for generic operations </li></ul>...
Editing <ul><li>Move </li></ul><ul><ul><li>by character, word, sentence, paragraph, page </li></ul></ul><ul><li>Copy / Cut...
Files <ul><li>File names / completion / disambiguation </li></ul><ul><li>Remote files (ange-ftp / tramp) </li></ul><ul><li...
Editing directories <ul><li>listing </li></ul><ul><li>create / rename / delete </li></ul><ul><li>bulk operations (mark / r...
Shell <ul><li>Inferior process </li></ul><ul><ul><li>filename completion </li></ul></ul><ul><ul><li>history ring </li></ul...
Help <ul><li>Info (manual) </li></ul><ul><li>Help on </li></ul><ul><ul><li>variables </li></ul></ul><ul><ul><li>functions ...
Programming modes : generic features <ul><li>Recognize top-level definitions </li></ul><ul><ul><li>go to begin / end, set ...
Cperl mode <ul><li>based on C-mode </li></ul><ul><ul><li>indenting </li></ul></ul><ul><ul><li>electric parentheses </li></...
Compiling and testing <ul><li>Compilation </li></ul><ul><ul><li>launch compiler subprocess (&quot;perl&quot;, &quot;gcc&qu...
Searching <ul><li>builtin support for &quot;grep&quot; </li></ul><ul><li>ack.el : adaptation for &quot;ack&quot; </li></ul...
Autocompletion <ul><li>Static sources </li></ul><ul><ul><li>Tags </li></ul></ul><ul><ul><li>Language-specific doc </li></u...
External filters <ul><li>Ex: perltidy </li></ul><ul><ul><li>; tidy perl code on region </li></ul></ul><ul><ul><li>(defun p...
Version control <ul><li>generic version control (VC) </li></ul><ul><li>psvn.el : SVN support </li></ul><ul><ul><li>status ...
Differences / patches <ul><li>ediff-mode </li></ul><ul><ul><li>both versions side-by-side (horizontal or vertical) </li></...
perlcritic <ul><li>mode  perlcritic.el  distributed with Perl::Critic </li></ul><ul><ul><li>apply on buffer </li></ul></ul...
Emacs::EPL <ul><li>Perl-Emacs IPC integration, followup to &quot;Perlmacs&quot; </li></ul><ul><li>looks like this was very...
Devel::PerlySense <ul><li>Perl process in the background </li></ul><ul><li>Lots of features </li></ul><ul><ul><li>links to...
Sepia <ul><li>last distrib May 09 </li></ul><ul><li>Inspired by Emacs Lisp dev. philosophy </li></ul><ul><li>Features </li...
Emacs::PDE <ul><li>last distrib July 2008 </li></ul><ul><li>Features (pde-load) </li></ul><ul><ul><li>projects </li></ul><...
Upcoming SlideShare
Loading in...5
×

Emacs, a performant IDE for Perl

5,516

Published on

Emacs is much more than a source code editor : it provides a rich integrated development environment for Perl developers. This guided tour will show how to take advantage of Emacs basic features (modes, abbreviations, autocompletion, macros, directory editor, undo, etc.), how to run and debug within Emacs, and how to integrate with external utilities such as ctags, ack, perltidy, perlcritic, subversion.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,516
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
54
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Emacs, a performant IDE for Perl

  1. 1. Emacs, a performant IDE for Perl Tutorial for YAPC.:EU:::2009, Lisbon [email_address] Département Office
  2. 2. Overview <ul><li>Intended audience </li></ul><ul><ul><li>Emacs newcomers </li></ul></ul><ul><ul><li>[ seasoned Emacs users … may find some additional tips ] </li></ul></ul><ul><ul><li>curious … </li></ul></ul><ul><li>Topics </li></ul><ul><ul><li>Intro </li></ul></ul><ul><ul><li>Emacs concepts </li></ul></ul><ul><ul><li>General editing </li></ul></ul><ul><ul><li>Perl programming </li></ul></ul><ul><ul><li>External tools </li></ul></ul><ul><ul><li>Emacs-Perl integration : extension packages </li></ul></ul>
  3. 3. What is Emacs ? <ul><li>&quot;Emacs is the extensible, customizable, self-documenting real-time display editor&quot;. </li></ul><ul><ul><li>advanced : provides much more than simple insertion and deletion. It can control subprocesses, indent programs automatically, show two or more files at once, and edit formatted text. </li></ul></ul><ul><ul><li>self-documenting : can type C-h at any time to find out what the options are. </li></ul></ul><ul><ul><li>customizable : thousands of variables </li></ul></ul><ul><ul><li>extensible : internal Lisp interpreter </li></ul></ul><ul><ul><li>feature-rich : thousands of commands </li></ul></ul>
  4. 4. Emacs history <ul><li>early 1970s : initial work on PDP computers (MIT Labs) </li></ul><ul><li>1976 : first release </li></ul><ul><li>1981 : Gosling Emacs on Unix </li></ul><ul><li>1986 : GNU Emacs 15.34 </li></ul><ul><li>1991 : XEmacs fork (formerly Lucid Emacs) </li></ul><ul><li>2008: GNU Emacs 22.3 </li></ul>
  5. 5. Emacs main concepts <ul><li>buffer : basic editing unit (text being edited). Can be bound to various contents like : </li></ul><ul><ul><li>file (local/remote) </li></ul></ul><ul><ul><li>computed content (listings, compilation results, shell, email, etc.) </li></ul></ul><ul><ul><li>external process </li></ul></ul><ul><li>window : screen area for displaying buffer content </li></ul><ul><li>frame : OS window </li></ul><ul><li>mode : set of options for editing some kind of content </li></ul><ul><ul><li>major mode : mutually exclusive </li></ul></ul><ul><ul><li>minor mode : additional options (plugin) </li></ul></ul>
  6. 6. Other concepts <ul><li>region : portion of buffer between mark and point </li></ul><ul><li>rectangle : rectangular area instead of linear text </li></ul><ul><li>register : memory for storing text / position / rectangle </li></ul><ul><li>macro : recorded sequence of keys </li></ul><ul><li>desktop : saved Emacs session </li></ul>
  7. 7. User input <ul><li>Input events </li></ul><ul><ul><li>character events </li></ul></ul><ul><ul><li>modifiers : <CTRL>, <ALT>, <META>, <SUPER> </li></ul></ul><ul><ul><li>mouse, scroll, click, focus, etc. </li></ul></ul><ul><li>Key sequence </li></ul><ul><ul><li>prefix key  keymap. Ex: </li></ul></ul><ul><ul><ul><li>C-x General extended commands </li></ul></ul></ul><ul><ul><ul><li>C-h Help commands </li></ul></ul></ul><ul><ul><ul><li>C-c Mode-specific extended commands </li></ul></ul></ul><ul><ul><li>complete key  command </li></ul></ul><ul><li>Keymap </li></ul><ul><ul><li>binding key  command </li></ul></ul><ul><ul><li>global / local </li></ul></ul>
  8. 8. Entering commands/args in minibuffer <ul><li>Auto-completion </li></ul><ul><li>Default argument </li></ul><ul><li>Editing (cut/paste/move/etc.) </li></ul><ul><li>Command history </li></ul>
  9. 9. Modes may implement … <ul><li>additional commands </li></ul><ul><li>local implementation for generic operations </li></ul><ul><ul><li>ex: comment-region, indent-region </li></ul></ul><ul><li>syntax highlighting </li></ul><ul><li>local keymaps </li></ul><ul><li>local menus </li></ul><ul><li>modifications to the display (ex. status line) </li></ul><ul><li>hooks </li></ul>
  10. 10. Editing <ul><li>Move </li></ul><ul><ul><li>by character, word, sentence, paragraph, page </li></ul></ul><ul><li>Copy / Cut / Paste </li></ul><ul><ul><li>kill ring : history of killed fragments </li></ul></ul><ul><li>Search / Replace </li></ul><ul><ul><li>incremental / regex </li></ul></ul><ul><ul><li>word search (without regard to punctuation) </li></ul></ul><ul><ul><li>clever case substitutions </li></ul></ul><ul><ul><li>recursive edit </li></ul></ul><ul><li>Abbrevs </li></ul><ul><li>Undo </li></ul>
  11. 11. Files <ul><li>File names / completion / disambiguation </li></ul><ul><li>Remote files (ange-ftp / tramp) </li></ul><ul><li>Archives / compressed files </li></ul><ul><li>Mode chosen automatically from name or content </li></ul><ul><li>Bookmarks (filename / position / comment) </li></ul><ul><li>Shadowing (automatic replication) </li></ul><ul><li>Filesets </li></ul>
  12. 12. Editing directories <ul><li>listing </li></ul><ul><li>create / rename / delete </li></ul><ul><li>bulk operations (mark / regexp ) </li></ul><ul><li>open subdirectories in same buffer </li></ul><ul><li>chmod, mkdir, etc. </li></ul><ul><li>exec shell command on file(s) </li></ul>
  13. 13. Shell <ul><li>Inferior process </li></ul><ul><ul><li>filename completion </li></ul></ul><ul><ul><li>history ring </li></ul></ul><ul><ul><li>editing command-line </li></ul></ul><ul><ul><li>directory tracking </li></ul></ul><ul><ul><li>remote host (telnet, rlogin, etc) </li></ul></ul><ul><li>Eshell </li></ul><ul><ul><li>no process, all done in Emacs </li></ul></ul>
  14. 14. Help <ul><li>Info (manual) </li></ul><ul><li>Help on </li></ul><ul><ul><li>variables </li></ul></ul><ul><ul><li>functions </li></ul></ul><ul><ul><li>keys </li></ul></ul><ul><ul><li>bindings </li></ul></ul><ul><ul><li>mode </li></ul></ul><ul><ul><li>apropos </li></ul></ul>
  15. 15. Programming modes : generic features <ul><li>Recognize top-level definitions </li></ul><ul><ul><li>go to begin / end, set region (C-M-h), imenu </li></ul></ul><ul><li>Indentation </li></ul><ul><ul><li>clever syntax parsing; various indent styles (K&R, BSD, Gnu, etc.) </li></ul></ul><ul><li>Balanced parentheses </li></ul><ul><ul><li>begin / end, up / down, kill, </li></ul></ul><ul><ul><ul><li>(C-M-LEFT, C-M-UP, ..) </li></ul></ul></ul><ul><ul><li>blink-matching </li></ul></ul><ul><li>Comments </li></ul><ul><ul><li>insert, realign, comment / uncomment region, reformat </li></ul></ul><ul><li>Syntax highlighing </li></ul><ul><li>Restricting editing scope </li></ul><ul><ul><li>hideshow minor mode </li></ul></ul><ul><ul><li>narrowing </li></ul></ul><ul><ul><ul><li>(C-x n d / w) </li></ul></ul></ul><ul><li>Autocompletion </li></ul><ul><li>Electric characters </li></ul><ul><ul><li>automatic reindent / newline </li></ul></ul><ul><li>Tags support </li></ul>
  16. 16. Cperl mode <ul><li>based on C-mode </li></ul><ul><ul><li>indenting </li></ul></ul><ul><ul><li>electric parentheses </li></ul></ul><ul><ul><li>automatic expansion (if, else, while, do, foreach, …) </li></ul></ul><ul><ul><li>syntax highlighting </li></ul></ul><ul><ul><li>binding to perlinfo </li></ul></ul><ul><ul><li>menu, tools </li></ul></ul><ul><ul><li>perldb : gud bindings </li></ul></ul><ul><ul><ul><li>next / step </li></ul></ul></ul><ul><ul><ul><li>break (C-x SP) </li></ul></ul></ul>
  17. 17. Compiling and testing <ul><li>Compilation </li></ul><ul><ul><li>launch compiler subprocess (&quot;perl&quot;, &quot;gcc&quot;, &quot;make&quot;, etc.) </li></ul></ul><ul><ul><li>mod-compile.el : additional layer </li></ul></ul><ul><ul><ul><li>adapt compilation command to current language / context </li></ul></ul></ul><ul><ul><li>parse errors and navigate to source files </li></ul></ul><ul><ul><li>usual Emacs commands for viewing results / debug logs </li></ul></ul><ul><li>GUD (Grand Unified Debugger) </li></ul><ul><ul><li>shell buffer </li></ul></ul><ul><ul><li>navigate to source files </li></ul></ul>
  18. 18. Searching <ul><li>builtin support for &quot;grep&quot; </li></ul><ul><li>ack.el : adaptation for &quot;ack&quot; </li></ul><ul><li>navigate in matched files like for the compilation buffer </li></ul>
  19. 19. Autocompletion <ul><li>Static sources </li></ul><ul><ul><li>Tags </li></ul></ul><ul><ul><li>Language-specific doc </li></ul></ul><ul><li>More context-aware </li></ul><ul><ul><li>Emacs extensions : Sepia, PerlySense </li></ul></ul><ul><li>Dabbrev </li></ul><ul><ul><li>most recent, preceding word for which this is a prefix </li></ul></ul><ul><ul><li>if none, search following words </li></ul></ul><ul><ul><li>if none, search other &quot;friend&quot; buffers </li></ul></ul><ul><li>Hippie-expand </li></ul><ul><ul><li>ring of try functions </li></ul></ul><ul><ul><ul><li>try-complete-file-name </li></ul></ul></ul><ul><ul><ul><li>try-expand-all-abbrevs </li></ul></ul></ul><ul><ul><ul><li>try-expand-line </li></ul></ul></ul><ul><ul><ul><li>try-expand-dabbrev </li></ul></ul></ul><ul><ul><ul><li>try-expand-whole-kill </li></ul></ul></ul>
  20. 20. External filters <ul><li>Ex: perltidy </li></ul><ul><ul><li>; tidy perl code on region </li></ul></ul><ul><ul><li>(defun perltidy () </li></ul></ul><ul><ul><li>&quot;run perltidy on the current region or buffer.&quot; </li></ul></ul><ul><ul><li>(interactive) </li></ul></ul><ul><ul><li>(shell-command-on-region (point) (mark) </li></ul></ul><ul><ul><li>&quot;perltidy -q&quot; nil t)) </li></ul></ul><ul><ul><li>(global-set-key &quot;C-ct&quot; 'perltidy) </li></ul></ul>
  21. 21. Version control <ul><li>generic version control (VC) </li></ul><ul><li>psvn.el : SVN support </li></ul><ul><ul><li>status </li></ul></ul><ul><ul><ul><li>dired-like </li></ul></ul></ul><ul><ul><li>log </li></ul></ul><ul><ul><li>ediff </li></ul></ul><ul><li>similar modes for git </li></ul>
  22. 22. Differences / patches <ul><li>ediff-mode </li></ul><ul><ul><li>both versions side-by-side (horizontal or vertical) </li></ul></ul><ul><ul><li>ediff commands </li></ul></ul><ul><ul><ul><li>previous / next </li></ul></ul></ul><ul><ul><ul><li>copy A  B / B  A </li></ul></ul></ul><ul><ul><li>apply patches (multifiles OK) </li></ul></ul>
  23. 23. perlcritic <ul><li>mode perlcritic.el distributed with Perl::Critic </li></ul><ul><ul><li>apply on buffer </li></ul></ul><ul><ul><li>apply on region </li></ul></ul><ul><ul><li>parse output </li></ul></ul><ul><li>other solution: treat as a standard compile command </li></ul><ul><ul><li>must configure .perlcriticrc so that Emacs understands filenames </li></ul></ul><ul><ul><li>verbose = %f:%l:%c: %m, %e (%p, severity %s) </li></ul></ul>
  24. 24. Emacs::EPL <ul><li>Perl-Emacs IPC integration, followup to &quot;Perlmacs&quot; </li></ul><ul><li>looks like this was very nice work </li></ul><ul><ul><li>adapted environment for running Perl under Emacs </li></ul></ul><ul><ul><ul><li>redefine STDIN, STDOUT as hooks to Emacs minibuffer </li></ul></ul></ul><ul><ul><ul><li>populate ENV </li></ul></ul></ul><ul><ul><ul><li>… </li></ul></ul></ul><ul><ul><li>can write Emacs modules in Perl instead of elisp ! </li></ul></ul><ul><li>last distribution dates back to 2001, using Perl 5.004 </li></ul><ul><li>couldn't get it to work  </li></ul>
  25. 25. Devel::PerlySense <ul><li>Perl process in the background </li></ul><ul><li>Lots of features </li></ul><ul><ul><li>links to doc </li></ul></ul><ul><ul><li>class hierarchy analysis and method analysis </li></ul></ul><ul><ul><li>jump to definition / class </li></ul></ul><ul><ul><li>run / debug </li></ul></ul><ul><ul><li>run tests </li></ul></ul><ul><ul><li>interact with ack </li></ul></ul><ul><ul><li>notion of &quot;project&quot; </li></ul></ul><ul><ul><li>file templates </li></ul></ul><ul><li>but very CPU-intensive and slow  </li></ul>
  26. 26. Sepia <ul><li>last distrib May 09 </li></ul><ul><li>Inspired by Emacs Lisp dev. philosophy </li></ul><ul><li>Features </li></ul><ul><ul><li>completion on partial words, i.e. L:U  List::Util </li></ul></ul><ul><ul><li>inferior Perl process with REPL loop </li></ul></ul><ul><ul><li>analyses opcodes </li></ul></ul><ul><ul><li>links to doc, to func definitions, to modules </li></ul></ul><ul><li> only recognizes core modules/functions </li></ul><ul><ul><li>didn't figure how to let it read perl/site/lib ! </li></ul></ul>
  27. 27. Emacs::PDE <ul><li>last distrib July 2008 </li></ul><ul><li>Features (pde-load) </li></ul><ul><ul><li>projects </li></ul></ul><ul><ul><li>smart compile (C-c r) / debug </li></ul></ul><ul><ul><li>tags / menus / tree view (C-c C-v TAB) </li></ul></ul><ul><ul><li>perldoc integration with browser (C-c C-v RET, C-c C-v C-p) </li></ul></ul><ul><ul><li>special indenting mode </li></ul></ul><ul><ul><li>integrate with perltidy / perlcritic </li></ul></ul><ul><ul><li>interactive perl shell </li></ul></ul><ul><li> no install problems </li></ul><ul><li>need to learn more </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×