----BEGIN CLASS---- [13:57] #startclass [13:57] Roll call [13:57] Bhavin Gandhi [13:58] Akshay Gaikwad [13:58] Anu Kumari Gupta [13:58] Devesh Verma [13:58] Today, I have few small topics to address, and we will go through them one by one. [13:58] Ananyo Maiti [13:59] The first topic is on "Centering commands". [13:59] Piyush Aggarwal [13:59] Open GNU Emacs using $ emacs -Q [13:59] pooja sulakhe [14:00] Sandeep Kumar CHoudhary [14:00] In the scratch buffer, you can type, say, "The GNU Emacs", and to center the text, you can use: [14:00] => M-x set-justification-center [14:00] It is a good practice to keep code within 80x25, and GNU Emacs will center the text for this width. [14:01] Similarly, you can justify the text to the right using: [14:01] => M-x set-justification-right [14:01] Also, you can justify the text to the left using: [14:01] => M-x set-justification-left [14:03] Also, if you select the text, "The GNU Emacs", you can center the defined region using: [14:03] => M-x center-region [14:03] Next, let us look at some basic "Rectange commands". [14:04] We have already seen its use in Org tables. Consider the following text in your *scratch* buffer: [14:04] 1 2 3 [14:04] 4 5 6 [14:04] 7 8 9 [14:05] You can selectively just cut the columns two (2, 5, 8) and three (3, 6, 9) [14:05] ! [14:06] Place your cursor on 2, and press C-space to mark it. Then move your cursor down (C-n, C-n) till you reach end of digit '9'. [14:06] Then you to delet the rectangle and store it, use: [14:06] => C-x r k [14:06] next [14:06] what do you mean by the term "defined region" in last centering command, mbuf? [14:06] brute4s99, highlighted or selected region [14:06] oh, got it ! [14:07] If you want to insert the last killed rectangle, you can use: [14:07] => C-x r y [14:07] If you want to delete a rectangle and not store it, use: [14:07] => C-x r d [14:08] You can select a rectangular region, and insert a blank rectangle in the area marked using: [14:08] => C-x r o [14:09] If you want to delete this rectangle that has whitespace in it, you can use: [14:09] => M-x delete-whitespace-rectangle [14:09] Suppose, you have the following rectangle: [14:09] 1 2 3 [14:10] 4 5 6 [14:10] 7 8 9 [14:10] And, you keep the cursor on 3, mark it, and select down (C-n C-n) till end of 9 (basically to select the rectangle 3, 6, 9), you can replace these entries with a string using: [14:10] => C-x r t [14:11] After you press 't', in the minibuffer you will be prompted with the message, "String rectangle:", and if you input '*' [14:11] Your rectangle will now become: [14:11] 1 2 * [14:11] 4 5 * [14:11] 7 8 * [14:12] You can also prompt for a string and insert a rectangle using: [14:12] => M-x string-insert-rectangle [14:13] If you want to blank out the area marked as a rectangle using spaces, you can use: [14:13] => C-x r c [14:14] Next, I want to discuss on modes in GNU Emacs. [14:14] We have both major modes and minor modes available. [14:14] ! [14:14] A buffer can be in only one major mode at a time. So, you cannot operate two major modes at the same time on a single buffer. [14:15] Let us say you ar writing some HTML code, and the filename ends with .html. GNU Emacs will recognize that, and will set HTML mode in the modeline. [14:16] So "HTML mode" is a major mode that helps you to work on specific files. [14:16] In addition to major modes, you can hove one or more minor modes enabled in the buffer. [14:16] Some minor modes are to assist the major modes, or can be used independently as well. [14:17] Minor modes "define a particular aspect of Emacs' behaviour and can be turned on and off within a major mode." [14:18] An example of a minor mode is the "Auto-save mode", which saves your file automatically [14:18] Irrespective of which file you are working on, this minor mode can be enabled. [14:19] One example of minor-mode we will try next is "Auto-fill mode". [14:19] Let us say you are writing text, and you want the text to word wrap after or close to 80 columns. [14:19] You can turn on the auto-fill mode using: [14:20] => M-x auto-fill-mode [14:20] You will see in the minibuffer the following text: "Auto-Fill mode enabled in current buffer" [14:20] Also in the modeline, you see the text "Fill" [14:20] Now, start typing text in the current buffer, and you will see that GNU Emacs automatically word wraps neatly. [14:21] If you are writing a blog, or article, or a book, any voluminous content, this is quite handy! [14:21] You can turn off this feature using: [14:21] => M-x auto-fill-mode [14:22] Now, you will see the following text in the minibuffer: "Auto-Fill mode disabled in current buffer" and the modeline will also not have the text "Fill" in it. [14:22] next [14:22] it's about rectange commands, I'll ask it later [14:23] brute4s99, okay [14:24] Let us now move on to Emacs customization [14:25] We are in the nineth class, and I did not want to talk about Emacs customization earlier because I wanted you to get to know the core commands [14:25] If we had started with customization earlier, then each one of your Emacs version and changes will be different, and we will spend time only troubleshooting, and not focusing on the core commands [14:26] So, I wanted all of you to start with the basic Emacs version (26.1) so that we have a common ground to learn [14:26] Now when you learn to customize Emacs to your needs, you can explore how others have done it, and tailor it to your specific requirements [14:27] Just make sure that you revision control your Emacs configuration files. [14:27] We will start with simple changes in this session. [14:28] Since we have learnt to use the keyboard shortcuts effectively, we do not need the menu-bar that comes with the GUI version of GNU Emacs. [14:28] Create ~/.emacs file (~ refers to your HOME directory), and add the following in it: [14:29] (menu-bar-mode -1) [14:29] Close Emacs and start it simply with $ emacs [14:30] When you open Emacs again, you should not see the Menus. [14:30] Since we are not using the mouse, we also do not need the toolbar. So, add the following to your ~/.emacs [14:30] (tool-bar-mode -1) [14:31] Close and re-open Emacs again, and you should now not see the tool bar [14:31] Your .emacs is an Emacs Lisp file, and it is interpreted whenever GNU Emacs starts. [14:32] Basically, you will put all your customization in your Emacs configuration file(s), and start GNU Emacs in the morning, and you never close till you go to bed! [14:33] With these two options, you have more work area for your buffer to use. [14:33] I use these two options for the same reason. [14:33] I also do not like the scroll bar on the right, and hence use the following customization: [14:33] (scroll-bar-mode 0) [14:35] As you scroll the text, depending on where the cursor is, you have x% in the modeline. [14:35] I use that to see where in the buffer I am in. [14:35] Of course, you can do fancy modeline customizations (similar to VIM powerline) https://www.emacswiki.org/emacs/PowerLine [14:37] Because, I use laptops, I have the following to show me battery status in the modeline: [14:37] (display-battery-mode 1) [14:37] If you are using a laptop, it will show the battery percent available like [98.1%] in the modeline. [14:38] We have seen commands to switch to other window. I found the following customizations useful: [14:38] (global-set-key (kbd "C-0") 'delete-window) [14:38] (global-set-key (kbd "C-1") 'delete-other-windows) [14:38] (global-set-key (kbd "C-2") 'split-window-below) [14:38] (global-set-key (kbd "C-3") 'split-window-right) [14:39] Instead of doing C-x 0 or C-x 1, it is shorter. [14:39] Similarly, you should read how other people have customized their Emacs, and pick the ones that you want, and add it to your configuration. [14:41] With respect to packages available for Emacs, you can use Emacs Lisp Package Archive (ELPA), or MELPA https://melpa.org/#/ [14:41] Just do the following to see available packages: [14:41] => M-x list-packages [14:41] The packages are hyperlinked, you can click on them to see what the package is for. [14:42] It will also tell what you need to add to your configuration file in order to load it at start. [14:42] Do read more on installing Emacs packages to extend your setup for your needs. [14:42] As I had mentioned earlier, a tailored suit looks much better than a ready-made one. [14:43] Since, the customizations are tailored to your liking, it will help you in your way of productive working. [14:43] A number of Emacs starter kits are also available, which provide you with the common, essential configuration that you can get started with. [14:44] And then, you can customize it for your liking. [14:44] A list is available at https://www.emacswiki.org/emacs/StarterKits [14:45] So, I will leave it to you to decide on how you want to experiment and build your own version of Emacs to your liking. [14:46] I use a tool called Cask to setup and maintain my required packages in ~/.emacs.d, and have a minimal ~/.emacs [14:46] You can see that at https://gitlab.com/shakthimaan/cask-dot-emacs [14:47] Some people use John Wiegley's use-package, https://github.com/jwiegley/use-package, but, I haven't tried it yet [14:47] I also run an Emacs server when I boot the system, and just open Emacs clients, as required. [14:48] I had sent a link and video to watch on Emacs Lisp to the mailing list. I hope you have gone through it. [14:48] Lisp is a simple but powerful language. For now, just by going through the customization, you can understand what the constructs do. [14:49] As, you learn to read more Emacs Lisp, you will be able to write your own. [14:50] So, it is important to explore available packages and see how to enhance your Emacs for productivity. [14:51] I had used the book "Learning GNU Emacs" by Debra Cameron, James Elliott, Marc Loy, Eric Raymond and Bill Rosenblatt as reference. [14:51] The third edition came out in 2004. Most of the concepts still remain the same. If you want a hard copy, this book is useful. [14:52] Of course, complete the Emacs built-in tutorial, and review the commands we have discussed in the sessions. [14:52] A number of reference cards are already available for you. You can simply print them out and keep them handy. [14:53] This is the GNU Emacs reference card: https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf [14:53] There is a GNU Calc Reference card: https://www.gnu.org/software/emacs/refcards/pdf/calccard.pdf [14:54] You have an Org-Mode reference card: http://orgmode.org/orgcard.pdf [14:54] A number of videos and tutorials are also available online for you to watch and learn. [14:55] The Emacs Wiki also has lot of useful content. [14:55] You should also hang around in #emacs on irc.freenode.net, as there a number of users there. [14:55] Are there any questions? [14:56] https://www.emacswiki.org/emacs/SiteMap [14:56] ! [14:56] next [14:56] can you please shed light on some use cases where rectange commands might come in handy? [14:56] brute4s99, you will find it useful in Org-mode tables [14:57] oh, I am yet to go through that log. [14:57] brute4s99, first practice the commands, and see what they do. [14:57] brute4s99, now, you should start using GNU Emacs on a daily basis. [14:58] brute4s99, for whatever tasks you do, try to see what functionality can be extended to make it better for you. [14:58] brute4s99, talk to people, read online as well on how people use Emacs, watch videos [14:58] brute4s99, the entire Emacs environment that you build over the years, will last you a life time! [14:59] okay, mbuf! I believe given ample practice, I can build an Emacs home as well! :) [14:59] Okay [14:59] Roll call [14:59] Piyush Aggarwal [14:59] Sandeep Kumar Choudhary [14:59] Bhavin Gandhi ----END CLASS----