----BEGIN CLASS---- [13:57] #startclass [13:57] Roll call [13:58] Soniya Vyas [13:58] Bhavin Gandhi [13:58] Ananyo Maiti [13:58] tabrez khan [13:59] Today, let us start by learning some Info commands. A number of manuals are available in the .info format and can be read inside GNU Emacs. [14:00] Info documents are hypertext manuals. Open GNU Emacs first using: [14:00] => $ emacs -Q [14:00] And then to enter into the Info directory, use: [14:00] => M-x info [14:01] This will open up a *info* (dir) buffer. You can quit Info using: [14:01] => q [14:01] Just like any other buffer, the basic navigation commands will continue to work. But, you will see hyperlinked (underlined) links in the document too. [14:02] You can move to the next menu item or cross-reference using: [14:02] => Tab [14:02] You can move to the previous menu item using: [14:02] => Shift-Tab [14:03] These are extensive hypertext manuals available in the system that you can refer anytime. [14:04] Vaibhav Kaushik [14:04] You do not need to go to the Internet always. Learning to refer to documentation offline can be handy, especially if you are travelling or have poor network connectivity [14:05] Move the cursor to the "Emacs FAQ" hyperlink, and to enter into the document, press: [14:05] => [14:05] This document again has a sub-menu. [14:06] This is now the *info* (efaq) buffer [14:06] You can open the first topic at this level using: [14:06] => n [14:07] This will open the "1 FAQ notation" chapter. If you press "n" again, you will move to the second chapter, "2 General Questions". [14:07] If you want to to the previous topic at this level, you can use: [14:07] => p [14:08] If you want to move up a level, i.e., back to the "The GNU Emacs FAQ" top page, you can use: [14:08] => u [14:09] You can search the index for a topic using: [14:09] => i [14:10] Emacs will prompt in the minibuffer with "Index topic:", and let's say you input "bug" and hit enter [14:10] It will take you to the first occurrence of 'bug' and it opens up "5.4 How do I debug a '.emacs' file?" section [14:10] At the minibuffer, it suggests you to use ',' to go to the next matching occurrence [14:11] Use two 'u' to come back to the top-level "The GNU Emacs FAQ" buffer [14:11] You can select a menu item through the keyboard using: [14:11] => m [14:12] At the minibuffer, you will get a prompt, "Menu item:", and if you input "bug" and hit enter, it will take you the "6 Bugs and problems" [14:13] Anytime, you can move to the top node using: [14:13] => t [14:13] If you want to go to the last node you visited, you can use: [14:13] => l [14:14] You can also go to a specific node using: [14:14] => g [14:15] Emacs will prompt in the minibuffer with the message, "Go to node:" and you can type "Problems with" and hit TAB, and Emacs will try to auto-complete for you. [14:15] You can use "Problems with Shell Mode", and it will directly open that section for you [14:16] You can also search for a regex using: [14:16] => s [14:16] At the minibuffer, Emacs will prompt with "Regexp search:" and you can input "^RMS", and it will take you to the first matching occurence of the same [14:17] The info documentation is quite expensive, and you are encouraged to read them, whenever you have time [14:17] There is also a built-in info tutorial, also written in Info! You can try that out using: [14:17] => h [14:18] Going through this tutorial is a homework for you. [14:18] This covers some basic Info commands [14:20] Next, I want you to learn how create keyboard macros in GNU Emacs [14:21] Commands that you type often can be created as a macro, so that, you don't have to type them manually [14:21] I will tell you now how to create a basic macro. [14:21] Switch to your *scratch* buffer where we can now experiment with macros [14:22] To start a macro, you need to use: [14:22] => C-x ( [14:22] Now, we are going to define the macro. Just follow these commands, and then I will explain what these are for: [14:23] => C-a C-x C-k C-i [14:23] You can now close the macro definition using: [14:23] => C-x ) [14:24] C-a means that you are moving the cursor to the beginning of the line [14:24] C-x C-k C-i is to insert a starting counter, and it will output "0" [14:24] Now, when you press enter, the cursor will go to the next line. This is so that, we are preparing to execute the macro again in a new line. [14:25] Now, to execute the macro, you can use: [14:25] => C-x e [14:25] You can tell Emacs to execute this macro 10 times using: [14:25] => C-u 10 C-x e [14:26] and it will output the numbers in increasing order. [14:26] Before defining the macro, you can also define the starting counter you want to use with C-x C-k C-c. [14:27] The keyboard macro is for any combination of key sequence that you repeatedly do. You can also bind this to a shortcut, and save it for future use. [14:30] I will give some time for you to try the above [14:31] There are some exercises here https://github.com/bzg/emacs-training/blob/master/exercises.org that you can try as homework [14:32] Let us now look at Ediff commands [14:33] Create /tmp/one.txt with the following contents: [14:33] GNU Emacs is, an operating system, [14:33] Which unlike many others, is truly, a gem [14:33] Its goodies can be installed, using RPM [14:33] Or you can use ELPA, which has already packaged them [14:33] Then, [14:33] you create /tmp/second.txt with the following contents: [14:34] Emacs is, an operating system, [14:34] Which unlike many others, is truly, a gem, [14:34] Its goodies can be installed, using RPM, [14:34] Or you can use ELPA, which has already packaged them. [14:38] Ediff can help you compare files [14:38] You can enter into it using: [14:38] => M-x ediff [14:38] At the minibuffer, it will prompt with the message: [14:39] "File A to compare (default ~/): ~/", and you can input "/tmp/one.txt" [14:39] It will again prompt in the minibuffer with the message: [14:39] "File B to compare (default one.txt):" and you can input "/tmp/second.txt" [14:40] Emacs will now open a separate frame for the Ediff control panel. Your original Emacs frame will have both the files open, the second.txt below the one.txt [14:41] There are commands that you can issue in the Ediff control panel that will execute on these two file buffers [14:41] For example, to switch between viewing the buffers from one above the other and side-by-side, you can use: [14:41] => | [14:42] Remember to issue the commands only in the Ediff control panel [14:42] You can scroll the buffer to the left using: [14:42] => < [14:42] You can scroll the buffers to the right using: [14:42] => > [14:44] If you want to copy current difference from A to B, you can use: [14:44] => a [14:44] This will make the changes from one.txt to second.txt [14:44] If you want to revert the change back, you should use: [14:44] => r b [14:45] This is because it is "b's" contents that you have modified, and hence you want to revert the change back [14:45] Similarly, if you want changes from second.txt to go to one.txt, you should use: [14:46] => b [14:46] And now one.txt will have its buffer modified. If you want to revert this change back, you should use: [14:46] => r a [14:47] If you have multiple differences between two files, you can move to the next difference using: [14:47] => n [14:48] You can move to the previous difference using: [14:48] => p [14:48] All these commands need to be given only in the Ediff Control Panel frame. [14:48] Of course, you can use your buffer navigation commands to move forward and backward. Everything is just a buffer. [14:49] In case you want to make either buffer in read-only mode, you can use: [14:49] => A [14:49] or [14:49] => B [14:49] The former will make /tmp/one.txt in read-only, so that you don't accidentally write to it. [14:49] Similarly, the latter will make /tmp/second.txt a read-only buffer. [14:50] If you know for sure that you only want to make changes one-way, from one file to another, then you can set the source buffer to read-only mode. [14:51] Anytime you want to save either of the buffers, you can use: [14:51] => w a [14:52] or [14:52] => w b [14:52] The former will save the contents in the A buffer, in our case, it is /tmp/one.txt [14:52] The latter will save the contents in the B buffer, in our case is /tmp/second.txt [14:53] The Ediff Info manual is also available, and you can open it from the Ediff Control Panel by issuing: [14:53] => E [14:53] Now that you are familiar in navigating Info manuals, you can read the Ediff manual as well! [14:55] To close the Ediff window and end the comparison session, you should use: [14:55] => q [14:55] This completes some basic usage of Ediff commands [14:56] Also, when you press 'q', at the minibuffer, you will prompted with the message, "Quit this Ediff session? (y or n)", and you can say 'y' to finish this session. [14:56] The Ediff control panel frame will close. [14:57] Any questions? [14:57] Roll call [14:57] Bhavin Gandhi [14:57] Ananyo Maiti ----END CLASS----