----BEGIN CLASS---- [13:57] #startclass [13:57] Roll call [13:59] pooja sulakhe [13:59] Mayank Singhal [13:59] <_ryuzaki3> Rituka Patwal [13:59] Priyanka Saggu [13:59] Today, we will be going through the basic commands with GNU Emacs Org mode. I hope you have all watched the video that I had sent to the mailing list. [14:00] Sandeep Kumar Choudhary [14:00] Org mode files end with .org, and can be used to store notes; plan your life, work, schedules; create blogs etc. [14:00] Open GNU Emacs using $ emacs -Q [14:01] and create a file, /tmp/test.org [14:01] An Org file consists of headings, sub-headings, and the nested level is denoted by the number of '*' [14:02] Power cut. BRB. [14:12] Back. Sorry! [14:13] I am running on battery on a mobile connection now. [14:14] Hopefully, it will last. As, I was saying earlier, we can use Org mode to organize topics under different headings [14:15] So, in /tmp/test.org, create your first heading with "* Emacs Org mode" (without the double quotes) [14:15] In the second line create: [14:15] ** VIdeo [14:15] s/VIdeo/video/ [14:16] In the third line, create "** Shortcuts". In the fourth line, "* Emacs Lisp", and in the fifth line, "* Magit". [14:16] So, "Video" and "Shortcuts" and sub-headings to the main topic "Emacs Org mode". [14:17] If you keep the cursor in the first line, you can rotate the current subtree between its states using: [14:17] => TAB [14:18] If you have a large file, with lot of headings, and sub-headings, you can rotate the entire buffer between states using: [14:18] => S-TAB [14:18] Here 'S' stands for Shift. [14:19] You can define properties for each task like EFFORT, ESTIMATE, ID, OWNER etc, and these are part of what is known as a drawer. So, if you want to see the entire file including the drawers, you can use: [14:19] => C-u C-u C-u TAB [14:19] Let us now look at motion commands in Org mode. You can go to the next heading using: [14:19] => C-c C-n [14:20] You can go to the previous heading using: [14:20] => C-c C-p [14:20] Notice that if you tried this from the first line, it will also go to the sub-heading (because it is also a heading) [14:20] But, if you want to go to the next heading at the same level, you can use: [14:20] => C-c C-f [14:21] If you want to go to the previous heading at the same level, you can use: [14:21] => C-c C-b [14:21] If you want to go backward to a higher level (say from Video or Shortcuts to the main heading Emacs Org mode), you can use: [14:21] => C-c C-u [14:22] If you want to jump to another place in the document, you can use: [14:22] => C-c C-j [14:22] The above command will prompt you for many options that you can select from. [14:22] Let us now move on to Structure Editing commands [14:23] You can insert a new heading/item at the current level using: [14:23] => M-RET [14:23] You can insert a new heading after a subtree using: [14:23] => C-RET [14:24] The different headings/items can be in different states. By default, TODO, DONE and no state. [14:24] You can customize these states as well, according to your taste. For example, in OBM, we use TODO, IN_PROGRESS, WAITING, CANCELLED, DONE. [14:25] In the next class, we will look at customization. These states are prepended to each heading. [14:25] To insert a TODO entry, or checbox item ([/]), you can use: [14:25] => M-S-RET [14:26] So, create one that says "* TODO Emacs reference card" [14:26] You can promote a heading using: [14:26] => M-LEFT [14:26] You can demote a heading using: [14:26] => M-RIGHT [14:27] But, if you want to promote the current subtree (including all its children), then you should use: [14:27] => M-S-LEFT [14:27] And, to demote the current subtree, you should use: [14:27] => M-S-RIGHT [14:27] You can move a subtree/list item up using: [14:27] => M-S-UP [14:28] You can move a subtree/list down using: [14:28] => M-S-DOWN [14:28] You can sort a subtree/region/plain-list using: [14:28] => C-c ^ [14:28] If you want to clone a subtree in the Org file, you can use: [14:28] => C-c C-x c [14:29] If you only want to copy the visible text, you can use: [14:29] => C-c C-x v [14:30] You can kill an entire subtree using: [14:30] => C-c C-x C-w [14:30] You can copy a subtree using: [14:30] => C-c C-x M-w [14:30] You can paste a subtree using: [14:30] => C-c C-x C-y [14:30] OR [14:30] C-y [14:31] Suppose, you are working on only one subtree, and you only want to focus on that, you can narrow the buffer to show only that subtree. This is done using: [14:31] => C-x n s [14:31] Again, if you want to widen it back to what it was, you can use: [14:31] => C-x n w [14:32] Let us now look at tables in Org mode. This can be useful for creating spreadsheets and working on them. [14:33] You can simply create table with fields separate by "|" (pipe) character. For example: [14:33] | Name | Age | [14:33] If you hit enter at the end of the line, for the next row, the pipes will be automatically created. [14:34] In the second row, you can enter your name, but the fields are not aligned. If you want to re-align the table without moving the cursor, you can use: [14:34] => C-c C-c [14:34] If you want to re-align the table, and move to the next field, you can use: [14:34] => TAB [14:35] Just re-aligning the table, and to move to the next row, you can use: [14:35] => RET [14:35] All these commands work inside the table. If you want to move to the beginning of the field, use: [14:35] => M-a [14:35] If you want to move to the end of the field, use: [14:35] => M-e [14:36] You can move a column to the left (swap) using: [14:36] => M-LEFT [14:36] You can move a column to the right using: [14:36] => M-RIGHT [14:36] If you do not want the current column, you can kill it using: [14:36] => M-S-LEFT [14:37] Basically, you are moving the column present on the right of the column you want to kill, to the left. [14:37] If you want to insert a new column to left of the cursor position, use: [14:37] => M-S-RIGHT [14:37] Basically, you are shifting the present column to the right. [14:38] You can move the current row up using: [14:38] => M-UP [14:38] You can move the current row down using: [14:38] => M-DOWN [14:38] You can kill the current row or horizontal line using: [14:38] => M-S-UP [14:38] If you want to insert a new row above the current line, you can use: [14:38] => M-S-DOWN [14:39] You can insert a horizontal line below the current row using: [14:39] => C-c - [14:39] You can also insert a horizontal line (hline) and move to the line below it using: [14:39] => C-c RET [14:40] You can cut a rectangular region in the table (after selecting it) using: [14:40] => C-c C-x C-w [14:40] If you want to copy the rectangular region, you should use: [14:40] => C-c C-x M-w [14:40] You can paste the rectangular region using: [14:41] => C-c C-x C-y [14:41] These Org tables can also be exported to tab-separated files, or CSV files. To export the Org table, use: [14:41] => M-x org-table-export [14:41] If you already have a tab-separated, or CSV file, you can import it into Org using: [14:42] => M-x org-table-import [14:42] You can sum the numbers in a current column/rectangle using: [14:42] => C-c + [14:43] In our | Name | Age | example, if you had two or more entries, you can find the sum of all the ages (not a realistic example, but, just for demonstration) [14:43] The result will be shown in the minibuffer. [14:44] Let's say, you add three more columns, consisting of "Physics", "Maths" and "Total". [14:44] In the "Total" column you can enter a formula to sum the scores of both Physics and Maths. [14:45] In the fifth column cell, you can specify: [14:45] => =$3+$4 [14:46] At the bottom of the table, you can also store the formula using: [14:46] => #+TBLFM: $5=$3+$4 [14:46] If you update the table, and would like to update the computed values, you can use the following on TBLFM entry: [14:46] => C-c C-c [14:47] If you want to set and evaluate a column formula, you can use: [14:47] => C-c = [14:47] If you want to set and evaluate a field formula, you can use: [14:47] => C-u C-c = [14:47] If you want to show line, column and formula reference, use: [14:47] => C-c ? [14:48] You can toggle the grid display for the table using: [14:48] => C-c } [14:48] There is also debugger support available. To turn it on/off use: [14:48] => C-c { [14:49] You can edit formulae in a separate buffer using: [14:49] => C-c ' [14:49] If you want to abort the formula editor, use: [14:49] => C-c C-q [14:49] You can also toggle the reference style in the formula editor using: [14:49] => C-c C-r [14:49] Let us now look at working with links in Org files. [14:50] To insert a link, you have to use: [14:50] => C-c C-l [14:51] It will prompt in the minibuffer for "Link:" and you can provide any URL. It will then prompt for the "Description:", and it will create a link with the description name in the file. [14:51] For example, under "** Video", you can create a link to the YouTube video that I shared in the mailing list. [14:51] You can also insert a link to a file using: [14:52] => C-u C-c C-l [14:52] You can edit the link at the point using: [14:52] => C-c C-l [14:52] If you want to open the link file inside GNU Emacs, you can use: [14:52] => C-c C-o [14:53] If you have a lot of links in the Org file, you can find the next link using: [14:53] => C-x C-x C-n [14:53] You can move to the previous link using: [14:53] => C-c C-x C-p [14:54] GNU Emacs can also show images in the buffer. So, if you have provided a link to an image file, and you want to see it, you can toggle inline display of linked images using: [14:54] => C-c C-x C-v [14:54] Let us move on to using Babel with Org. This allows you to run external programs from different programming languages, and store the results. [14:55] If you have a script, or playbook that you want to run, you can create an Org file with both documentation and commands. This style is called "Literate Programming". [14:56] You will first need to tell Emacs the languages for which you want to allow support to execute programs. [14:57] For this demonstration, let us stick to Bash. [14:57] Copy the following Emacs Lisp to your *scratch* buffer: [14:57] (org-babel-do-load-languages 'org-babel-load-languages '((shell . t))) [14:57] At the end of the last parenthesis, use: [14:57] => C-x C-e [14:58] This will basically evaluate this Emacs Lisp code dynamically, and you should see "nil" in the minibuffer. [14:58] Switch back to your /tmp/test.org file, and create the following code block: [14:58] => #+BEGIN_SRC sh [14:58] => date [14:58] => #+END_SRC [14:59] We are defining a code black for a shell script, and invoking the 'date' command in it. To execute this from GNU Emacs Org file, go to the BEGIN_SRC line, and use: [14:59] => C-c C-c [15:00] GNU Emacs will prompt in the minibuffer with the message, "Evaluate this sh code block on your system? (yes or no)". If you input 'yes', it will create a RESULTS code block with the output! [15:00] If you want to open the results of code block at point in another window, use: [15:00] => C-c C-o [15:01] You can view information about the code block at point using: [15:01] => C-c C-v I [15:01] If you have large number of code blocks, you can prefix them with a name, such as: [15:01] => #+NAME: DATE [15:02] The results that is generated will also have this name. So, you can go to a named code block using: [15:02] => C-c C-v g [15:02] You can go to a named result using: [15:02] => C-c C-v r [15:02] You can move to the head of the current block using: [15:02] => C-c C-v u [15:02] You can move to the next code block using: [15:02] => C-c C-v n [15:02] You can go to the previous code block using: [15:02] => C-c C-v p [15:03] You can execute all the code blocks in the current buffer using: [15:03] => C-c C-v b [15:04] GNU Emacs will prompt you before executing each one. This way, you can break down your solution, and analyse the results at each and every step. [15:04] Since, Emacs has headings, and sub-headings in a tree like structure, you can execute code blocks in the current subtree, as well, using: [15:04] => C-c C-v s [15:04] GNU Emacs can also compute the SHA1 hash of the current code block using: [15:05] => C-c C-v a [15:05] There is also provision to use the results of a code block execution in the next code block. You should be able to find how to do this online. This is left as homework. [15:06] As I had mentioned earlier, each heading or item or topic can be in different state, that is prepended to the topic. [15:06] You can rotate through these states for a current item using: [15:06] => C-c C-t [15:06] You can select the next state using: [15:06] => S-RIGHT [15:06] You can move to the previous state using: [15:07] => S-LEFT [15:07] You can toggle the ORDERED property in the drawer for the item using: [15:07] => C-c C-x o [15:07] You can set a priority for the current item. There are three options [A, B, C]. [15:07] You can set the priority for the current item using: [15:07] => C-c , [15:08] You will then be prompted to give any one of the values: A, B, or C. [15:08] To remove the priority from the current item, you can use: [15:08] => C-c , SPC [15:08] You can also raise/lower the priority of the current item using: [15:08] => S-UP [15:08] OR [15:08] => S-DOWN [15:09] If you have a checklist item [/], and sublists "- [ ]", you can toggle the checkpoint using: [15:09] => C-c C-c [15:09] Depending on the number of tasks completed, [/] will show like [5/10]. You can also choose to use [%], if you want. [15:10] Priorities are up to you, if you want to use them. You can also categorise tasks based on tags (like home, office, school, college etc.) [15:10] You can set a tag for the current heading using: [15:10] => C-c C-q [15:11] These (:office:, :home:, :school:, :college: etc.) are appended to the end of the line. [15:11] Since, everything is a buffer, you can also type them manually. But, if you want to re-align the tags in all the headings, you can use: [15:11] => C-u C-c C-q [15:12] You can define a property (included in the drawer) for an item using: [15:12] => C-c C-x p [15:14] For example, for the "* Emacs Lisp" task, you can create a property "OWNER: Name". Replace Name with your IRC nickname. [15:14] So, mine looks like this: [15:14] :PROPERTIES: [15:14] :OWNER: mbuf [15:14] :END: [15:14] You can define whatever properties you want for an item. [15:15] If you want to set an effort estimate for the topic, you can use: [15:15] => C-c C-x e [15:15] There is also an option to issue special commands in property lines using: [15:15] => C-c C-c [15:15] The properties can also be viewed in a column view. For example, you can define the following in your drawer: [15:15] :COLUMNS: %25ITEM %USERNAME %PASSWORD [15:16] :USERNAME: FOO [15:16] :PASSWORD: FOO123 [15:16] The %25ITEM specifies the width for each column. But, you can specify per column as well. [15:16] To see the drawer entries in column view, use: [15:16] => C-c C-x C-c [15:17] So, basically, you can create a passwords.org.gpg file, which is Org structured and is also encrypted. [15:17] You can have different headings according to your needs, such as - Home, Work, Social Media, Server, Bank etc. [15:18] The above command is useful to see the password for a particular entry. If you want to see the full value of the entry in column view, you can use: [15:18] => v [15:18] If you want to edit the value, use: [15:18] => e [15:18] If you want to make the column wider, you can use: [15:18] => > [15:19] If you want to make the column narrower in column view, you can use: [15:19] => < [15:19] You can also move the column left using: [15:19] => M-LEFT [15:19] You can move the column to the right using: [15:19] => M-RIGHT [15:19] If you want to quit column view, use: [15:19] => q [15:20] As I had mentioned earlier, Org files can be used to manage your life. [15:21] We already use that in Operation Blue Moon. The next important section is on timestamps. [15:21] There are only couple of important sections left. Please bear with me, while we complete these important sections. [15:22] You can treat each item in an Org file as a task that you want to perform. You will also find lot of online documentation on how people use Org to Get Things Done (GTD). [15:22] :D [15:22] Hey gang!!! How are we all? [15:23] If you want to prompt for date and insert a timestamp, use: [15:23] => C-c . [15:23] You will see that the calendar pops up, and you can select a date. [15:23] You can insert date and time using: [15:23] => C-u C-c . [15:24] So, the above two commands could have given you: [15:24] <2018-09-07 Fri> [15:24] <2018-09-07 Fri 20:54> [15:24] If you want to insert an inactive date, you can use: [15:24] => C-c ! [15:24] For example: [15:24] [2018-09-07 Fri] [15:25] hi everyone [15:25] The [] parenthesis says that the time is closed. [15:25] mbuf: That looks like screen key shortcuts / combos [15:25] wyoung: Lingeezer class is in progress. Do not disturb. [15:25] mbuf: ? [15:25] You can insert a deadline timestamp for an item using: [15:25] => C-c C-d [15:26] For the "Emacs Lisp" task item, I have given a deadline of: [15:26] DEADLINE: <2018-09-10 Mon> [15:26] You can also insert a scheduled timestamp using: [15:26] => C-c C-s [15:27] Again, for the Emacs Lisp task, I have scheduled it for: [15:27] SCHEDULED: <2018-09-10 Mon> [15:28] I can also give a time, or time range: [15:28] SCHEDULED: <2018-09-10 Mon 19:30-20:30> [15:28] You can create sparse tree with all deadlines using: [15:28] => C-c / d [15:29] If you have two timestamps, you can compute the time between them using: [15:29] => C-c C-y [15:29] For example: [2018-09-07 Fri 19:30]--[2018-09-07 Fri 21:00] => 1:30 [15:30] You can change timestamp at cursor +1 day using: [15:30] => S-UP [15:30] You can change the timestamp at cursor -1 day using: [15:30] => S-DOWN [15:31] You can open the calendar with the current date using: [15:31] => C-c > [15:31] You can insert timestamp matching the date in calendar using: [15:31] => C-c < [15:31] Before you start to work on a task, it is important to start the clock. So, you clock in using: [15:31] => C-c C-x C-i [15:32] You can stop the clock using: [15:32] => C-c C-x C-o [15:32] You can display the total subtree times using: [15:32] => C-c C-x C-d [15:32] You can then remove these displayed times using: [15:32] => C-c C-c [15:33] You can also generate a clock report and insert the table in the buffer using: [15:33] => C-c C-x C-r [15:33] Now, add the following Emacs Lisp to the *scratch* buffer and evaluate it: [15:33] (global-set-key "\C-ca" 'org-agenda) [15:34] After the closing parenthesis, use: [15:34] => C-x C-e [15:34] This will evaluate this Emacs Lisp expression. It basically assigns the org-agenda command to C-a. [15:35] Switch back to /tmp/test.org, and you can add this file to Emacs list of agenda files using: [15:35] => C-c [ [15:35] At the minibuffer, you will see "File added to front of agenda file list". [15:36] Ideally, you will have all your Org task related files in a directory, and you can add this to your Emacs configuration, which we will review in the next class. [15:36] If you want to remove the current file from the agenda, you can use: [15:36] => C-c ] [15:36] You can compile the agenda for the current week using: [15:37] => C-c a a [15:37] Hopefully, you have few tasks with scheduled and TODO items, and you should see them in the *Org Agenda* buffer. [15:37] You can compile a global TODO list using: [15:37] => C-c a t [15:38] You can compile the TODO list for specific keyword (say tag names) using: [15:38] => C-c a T [15:38] You can also match TODO keywords, properties using: [15:38] => C-c a m [15:38] If you want to only match TODO entries, you can use: [15:38] => C-c a M [15:39] You can also see stuck projects (unscheduled TODOs) using: [15:39] => C-c a # [15:39] A number of commands are available for you to work in the *Org Agenda* buffer. Let us go through them now: [15:40] You can ask Org to show the original location of the item in the Org file using: [15:40] => SPC [15:40] You can goto the original location in another window using: [15:40] => TAB [15:40] You can ask to show the subtree in indirect buffer using: [15:40] => C-c C-x b [15:40] If you want to delete all the other windows, and just keep the Agenda view, you can use: [15:40] => o [15:41] There is a view mode dispatcher available using: [15:41] => v [15:41] This will allow you to see the agenda for day, week, fortnight, month, year etc. [15:41] You can switch to the day view using: [15:41] => d [15:41] You can switch to the week view using: [15:41] => w [15:41] You can see the monthly agenda using: [15:41] => vm [15:42] You can see the yearly view using: [15:42] => vy [15:42] You can toggle entry text using: [15:42] => E [15:42] So, you can see the text in this item. [15:42] You can clock report using: [15:42] => R [15:42] If you want to see the clocked entries and toggle display of these logbook entries, you can use: [15:43] => l [15:43] If you have updated the Org file, and want to refresh the Org Agenda buffer to see the changes updated, you can use: [15:43] => g [15:43] You can display the next week's agenda using: [15:43] => f [15:43] You can see the previous week's agenda using: [15:43] => b [15:44] If you want to jump to today, use: [15:44] => . [15:44] If you want to goto a specific date in the agenda, use: [15:44] => j [15:44] If you want to change the state of the current TODO item, use: [15:44] => t [15:44] You can ask to show tags of the current headline using: [15:44] => : [15:44] OR [15:44] => T [15:44] If you are using the effort property in the drawer for an item, you can set it using: [15:45] => e [15:45] You can set the priority of the current item in the Agenda buffer itself, using: [15:45] => , [15:45] You can raise the priority of the current item using: [15:45] => S-UP [15:45] You can lower the priority of the current item using: [15:45] => S-DOWN [15:45] You can schedule the current item using (same shortcut): [15:45] => C-c C-s [15:46] You can set deadline for the current item (same shortcut) using: [15:46] => C-c C-d [15:46] You can change the timestamp for today using: [15:46] => > [15:46] If you want to start the clock on the current item use: [15:46] => I [15:46] If you want to stop the clock on the current item, use: [15:46] => O [15:47] If you want to cancel the clock on the current item, use: [15:47] => X [15:47] Even if you have missed stopping the clock, GNU Emacs gives you the option to correct the same. Or, you can also go and update the clock timings yourself, since it is a plain text file. [15:47] As long, as you follow the date, timestamp semantics used. [15:48] You can jump to the running clock entry using: [15:48] => J [15:48] Similar to Dired or Buffer List window, you can mark entries in the Org Agenda buffer using: [15:48] => m [15:48] You can unmark them using: [15:48] => u [15:49] You can then execute bulk actions on these marked items using: [15:49] => B [15:49] If you want to find the agenda cursor date in the built-in calendar, you can use: [15:49] => c [15:49] You can also ask to show the phases of the moon using: [15:49] => M [15:50] Sample output is shown below: [15:50] Monday, September 3, 2018: Last Quarter Moon 8:14am (IST) Sunday, September 9, 2018: New Moon 11:33pm (IST) Monday, September 17, 2018: First Quarter Moon 4:46am (IST) [15:50] You can ask for sunrise/sunset times using: [15:50] => S [15:50] You can ask to show holidays using: [15:50] => H [15:50] You can also ask to convert date to other calendars using: [15:50] => C [15:51] So, other calendars are like Gregorian, ISO, Julian, Hebrew, Islamic, French, Mayan, Persian, Chinese etc. [15:51] To quit Org Agenda buffer, use: [15:51] => q [15:52] You can export your Org files to text, HTML, and other formats using: [15:52] => C-c C-e [15:52] This will open up the *Org Export Dispatcher* buffer, and you have many options that you can try out. [15:52] Some others are iCalendar, ODT, LaTeX. [15:53] Last but not the least, you can read the Org Info manual provided with GNU Emacs using: [15:53] => M-x org-info [15:53] So, we have covered a lot today in GNU Emacs Org mode. Please do try them out during the weekend, and review them. [15:54] We will have our next session on Monday, September 10, 2018 at 1930 IST. [15:54] Are there any questions? [15:54] Roll call [15:55] Priyanka saggu [15:55] Mayank Singhal ----END CLASS----