├── LICENSE ├── README.md ├── emacsQuizEssentials0yr2022mo09day01hr09min01sec59.pdf ├── emacsQuizEssentials0yr2022mo09day01hr09min02sec12.pdf ├── emacsQuizEssentials0yr2022mo09day01hr09min03sec55.pdf ├── emacsQuizEssentials0yr2022mo09day01hr09min04sec24.pdf ├── emacsQuizEssentials0yr2022mo09day01hr09min04sec47.pdf ├── emacsQuizLatexyr2022mo09day01hr09min05sec27.pdf ├── emacsQuizLatexyr2022mo09day01hr09min06sec05.pdf ├── emacsQuizLatexyr2022mo09day01hr09min06sec22.pdf ├── emacsQuizLatexyr2022mo09day01hr09min06sec50.pdf ├── emacsQuizLatexyr2022mo09day01hr09min07sec07.pdf └── init.el /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Version](https://img.shields.io/static/v1?label=latex-emacs&message=0.2.4&color=brightcolor) 2 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) 3 | 4 | 5 | # A GNU Emacs profile for using LaTeX and Org in academic research 6 | 7 | ## Make writing tasks fun by disguising them as coding projects! 8 | 9 | This repo contains an `init.el` file (configuration file) for using LaTeX in GNU Emacs version 29. 10 | You can adapt it to other configurations of Emacs (e.g., Spacemacs, Doom, etc). 11 | The SciMax configuration probably has similar support built-in. 12 | See latex-emacs28 and latex-emacs30 for configurations that work with Emacs version 28 and Emacs version 30, respectively. 13 | 14 | Features include the following: 15 | 16 | * heavily customized auto-complete for LaTeX 17 | * AUCTeX 18 | * atomic-chrome (GhostText) 19 | * awesome-tabs (install from Github) 20 | * dashboard and dashboard-hackernews (keep abreast with the latest distractions) 21 | * org-mode 22 | * org-agenda 23 | * org-roam (capture templates include timestamps) 24 | * org-roam-ui (view your zettelkasten like a mind-maps in your browser, very cool, similar to the one in Obsidian) 25 | * pdf-tools 26 | * pdf-noter 27 | 28 | I built the latex-emacs profile on top of a configuration by [Alvaro Ortiz Troncoso](https://github.com/aot29/Emacs_Python_R_LaTeX). 29 | His configuration included the `auto-complete-auctex.el` package of Chris Monsanto from 2012. 30 | Although the autocompletion is out of style for Emacs fans at the cutting edge of package development, it works! 31 | 32 | I designed this configuration to support the efficient editing of academic documents in LaTeX. 33 | See the [Features](#Features) section below. 34 | See the [related repos](#Related) section below for LaTeX templates for the first manuscript submission, a writing log to accompany every writing project, a poster, a slideshow, a diary for 2022, and a diary for 2023. 35 | 36 | This configuration is compatible with [org-mode](https://de.wikipedia.org/wiki/Org-mode). 37 | Org-mode is an enhanced markdown that reads LaTeX code intermingled with org markup. 38 | Org-mode is very popular with Emacs users because the sections and subsections are easy to fold, and org documents are easy to export to many file formats. 39 | It evolved out of an outliner package. 40 | It greatly eases the creation of lists, so it is useful for planning and brainstorming. 41 | Org-mode also has a powerful org-agenda component for scheduling events. 42 | Many have tried to use org-mode to implement the Getting Things Done method of Jim Allen. 43 | Org-mode also powers the [org-roam](https://www.orgroam.com/) package, which implements electronically the [zettelkasten system](https://wiki2.org/en/Zettelkasten) or slip-box system of taking smart notes. 44 | 45 | 46 | In addition to Emacs, you can edit org-mode markdown in several other leading text editors like [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=BobbyBoyd.vs-org), so you can still use org-mode if you fear Emacs. 47 | Org-mode is responsible for the recent resurgence in the popularity of Emacs. 48 | (The median age of an Emacs user is about 33 years). 49 | The recurring annual [emacsconfs](https://emacsconf.org/) reflects this surge in popularity. 50 | The two-day conference is virtual and free. 51 | 52 | Org-mode supports literate programming with almost any programming language, although the latex-emacs init.el file is not configured for literate programming. 53 | Instead, see my complete configuration for [Emacs](https://github.com/MooersLab/configorg). 54 | Unlike the above configuration written in Emacs lisp (elisp), the complete configuration is wrapped in org-mode. 55 | It is a 6000-line literature programming document. 56 | I wrote the comments in org-mode; they flank blocks of elisp code. 57 | 58 | You can read an org-mode document into Emacs with the *latex-emacs* configuration, even though the latex-emacs init.el file does not call org-mode because the base distribution of Emacs now contains org-mode. 59 | See this [repo](https://github.com/MooersLab/manuscriptInOrg) for a manuscript template that can be edited in `org-mode`. 60 | For a writing log to be used in parallel to writing a manuscript in org-mode, see this [repo] (https://github.com/MooersLab/writingLogTemplateInOrg). 61 | 62 | I am keeping the *latex-emacs* configuration isolated from my main configuration to ease the development of *latex-emacs*. 63 | The *latex-emacs* profile also serves as a backup configuration when I break my main configuration, which happens less often these days. 64 | 65 | I use the following bash alias to start Emacs29 with the configuration stored in the folder *~/latex-emacs29*. 66 | Note that I am not hiding this folder in my top directory. 67 | The hindrance of hiding the Emacs configuration folder is greater than the benefit of not accidentally deleting it once in a lifetime. 68 | With my init.el file on GitHub, I can easily restore my Emacs configuration if disaster strikes. 69 | 70 | ```bash 71 | alias e29l='/Applications/Emacs29.0.5.app/Contents/MacOS/Emacs --init-directory ~/latex-emacs29'. 72 | ``` 73 | 74 | The **--init-directory** flag has been available as of January 2022 with Emacs version 29.0.5. 75 | This flag negates the need for the package chemacs2 and its slightly more complex setup. 76 | 77 | I made a second variant of the above alias for debugging: 78 | 79 | ```bash 80 | alias e29ld='/Applications/Emacs29.0.5.app/Contents/MacOS/Emacs --init-directory ~/latex-emacs29 --debug-init'. 81 | ``` 82 | 83 | 84 | ## Multiple versions of Emacs on the same computer 85 | 86 | You can have multiple versions of Emacs on your system; however, you must match the profiles to the Emacs version because the binaries in the `elpa` subfolder of the latex-emacs29 folder may not run with different versions of Emacs. 87 | 88 | No warranty is implied. 89 | Use at your own risk. 90 | 91 | I used this configuration to prepare the [presentation](https://github.com/MooersLab/BerlinEmacsAugust2022) given to the Berlin Emacs Meetup on 31 August 2022. 92 | 93 | ## Why LaTeX? 94 | 95 | LaTeX is the gold standard markup system for technical writing. 96 | 97 | - Combine a passion for coding with writing (i.e., make writing fun by disguising it as coding). 98 | - Code reuse: recycle old documents. 99 | - Precise control over the appearance of the output. 100 | - Equation typesetting par none. 101 | - Automated scaling and placement of figures. 102 | - Syntax highlighting of code fragments. 103 | - Reduced use of the mouse: More ergonomic. 104 | - Reduced context switching: Be more productive. 105 | - Slideshows as PDFs are immune to embarrassing font issues when presenting slides on another operating system. 106 | - Support for multi-part documents (books). 107 | - Precise control over typesetting of the bibliography. 108 | - Automated table of contents and list assembly. 109 | - Automated index generation. 110 | - Source files are compact and easy to share by e-mail. 111 | - You can put the source files under version control. 112 | - Overleaf supports collaborative writing. 113 | 114 | Most markdown variants do not support the automated generation of indices for large documents. 115 | Most literate programming projects built on top of markdown have this serious limitation, but org-mode does not. See the section `Why Org`. 116 | 117 | 118 | ## Why Emacs? 119 | 120 | Over the past several decades, many Emacs and package developers have developed a suite of packages to aid the writing of LaTeX documents. 121 | These features support efficient editing of LaTeX documents. 122 | 123 | In addition, you can extend Emacs with the Emacs Lisp programming language. 124 | Elisp is a variant of LISP that was customized to ease Emacs configuration. 125 | Emacs is a platform for building a customized text editor. 126 | You can customize your LaTeX environment and add functions to aid your workflow. 127 | 128 | Of course, other text editors have these features too, but Emacs is the most extensible. 129 | It is the ultimate editor. 130 | You might still use other editors, but Emacs will meet most of your needs. 131 | 132 | Emacs has been under development for 45 years. 133 | According to the [Lindy effect](https://wiki2.org/en/Lindy_Effect), it should be available for another 45 years. 134 | 135 | 136 | ## Why Overleaf? 137 | 138 | Overleaf is a web-based LaTeX editor. 139 | Overleaf is excellent for maintaining multiple writing projects and strongly supports collaborative editing. 140 | I find the Overleaf GUI intuitive and has good support for debugging. 141 | The GUI provides helpful tools for generating the code for tables of various sizes and for selecting images to be inserted into figure environments. 142 | It provides an outside view of the document. 143 | I use this feature to generate outline views of the slide shows I am developing in Beamer. 144 | I use this outline view to navigate to specific slides and to rearrange slides while editing the beamer file. 145 | Overleaf also has an extensive collection of attractive documentation about LaTeX, a nice supplement to TeX StackExchange. 146 | 147 | I have over 780 writing projects on Overleaf. 148 | These projects include grant applications, manuscripts, slideshows, and posters. 149 | I often use an old project as a template to make a new project. 150 | This saves a lot of time. 151 | 152 | I use it multiple times daily because I store my daily writing in a book document as my digital laboratory notebook. 153 | I speed up navigation to active projects by storing their URLs on a private homepage (index.html). 154 | 155 | I have subscribed to the Pro license for several years and have used Overleaf for six years. 156 | I recommend the free account to anyone trying to master LaTeX. 157 | I recommend the Pro license for anyone doing collaborative writing or managing dozens to 100s of projects. 158 | The Pro license enables you to use Git to make copies of your writing projects on your computer using Git. 159 | 160 | The reasons not to use Overleaf include the following: 161 | 162 | - pricey annual subscription 163 | - poor support for Emacs key bindings 164 | - lack of a system for storing snippets of custom LaTeX boilerplate 165 | - time spent in Overleaf is not time spent in Emacs (but see workaround solution below via GhostText) 166 | 167 | 168 | #### GhostText and Overleaf 169 | Overleaf does support a small subset of Emacs keybindings. 170 | Even better, if you select the legacy mode on Overleaf, you can send the text area to Emacs for editing via the GhostText plugin for your browser and the atomic-chrome package for Emacs. 171 | You can use snippets on the Emacs side of the websocket; the inserted code will appear immediately on the Overleaf side. 172 | My configuration for atomic-chrome is below: 173 | 174 | ```emacs-lisp 175 | ;; atomic-chrome, used to interact with GhostText extension for Google Chrome. 176 | (use-package atomic-chrome) 177 | (atomic-chrome-start-server) 178 | (setq atomic-chrome-default-major-mode 'python-mode) 179 | (setq atomic-chrome-extension-type-list '(ghost-text)) 180 | ;;(atomic-chrome-start-httpd) 181 | (setq atomic-chrome-server-ghost-text-port 4001) 182 | (setq atomic-chrome-url-major-mode-alist 183 | '(("github\\.com" . gfm-mode) 184 | ("overleaf.com" . latex-mode) 185 | ("750words.com" . latex-mode))) 186 | ; Select the style of opening the editing buffer by atomic-chrome-buffer-open-style. 187 | ; full: Open in the selected window. 188 | ; split: Open in the new window by splitting the selected window (default). 189 | ; frame: Create a new frame and window in it. You must be using some windowing package. 190 | (setq atomic-chrome-buffer-open-style 'split) 191 | ``` 192 | 193 | If you use the text area of Overleaf, 750words, or WriteHoney and you have Voice In plus installed in Google Chrom, you can carry out dictation in a text area that will be mirrored in Emacs via GhostText. 194 | The advantage of doing this over using the `whisper.el` package is that you can dictate in longer spurts, and you can use your custom voice triggers to activate the insertion of text replacements. 195 | 196 | For example, I abhor English contractions because I do not believe they will weather well over time. 197 | They also violate the principles of scientific writing, which are be clear, precise, and concise. 198 | Above all, scientific writing must be clear. 199 | Contractions reduce clarity, especially for non-native English speakers. 200 | I have mapped almost 200 contractions to their expansions. 201 | When I say an English contraction, it serves as a voice trigger that leads to the insertion of its expansion. 202 | This spares me the trouble of correcting these manually. 203 | I have also mapped expansions of acronyms to voice triggers so that I can accurately expand the acronym on the fly without looking it up for the 10th time. 204 | I have also mapped various kinds of LaTeX codes to voice triggers. 205 | See the bottom section of the Mooerslab GitHub landing page for more information about [how I use voice computing in my daily work](https://github.com/MooersLab#voice-computing). 206 | 207 | 208 | 209 | ### Advantages of using LaTeX in Emacs over Overleaf 210 | 211 | - The availability of the *yasnippets* package. You can build document templates and save them as yasnippet snippets. You then insert the document template into a new file upon entering the snippet name and hitting tab. 212 | - Powerful macros in AUCTeX support creating and editing new documents. 213 | - Syntax checking before compiling is available. See the keybinding lists below. 214 | - Terse and clear bug reporting during PDF compiling. 215 | - Preview a rendered version of a select region in the buffer. You remove the preview with a key binding. The preview allows you to check an equation's typesetting without going through the longer step of compiling the file into a PDF. 216 | 217 | 218 | ## Why Org-mode 219 | 220 | Org-mode includes support for document preparation, time management, and literate programming. 221 | Many people in the past decade were drawn to Emacs by org-mode. 222 | Org documents recognize the most commonly used features of LaTeX markup. 223 | You can use a LaTeX preamble in the front matter of your org file to use your favorite LaTeX packages and settings. 224 | You can make the PDF coming out of org look precisely like the PDF that you would generate from LaTeX. 225 | You can use LaTeX to build indices, glossaries, list of acronyms, lists the tables, list of figures, lists of code listings, list of equations, and so on. 226 | 227 | I now think of org-mode as a thin but very powerful wrapper around LaTeX. 228 | By utilizing org-mode, you gain the very easy-to-assemble tables that org-mode provides. 229 | You also gain some very convenient ways of utilizing Gnuplot to quickly generate plots. 230 | You gain integration with org-roam for knowledge management because the notes in the system are org files. 231 | You can use this knowledge management in lieu of or in addition to an annotated bibliography. 232 | You gain interactive computing in source blocks. 233 | 234 | 235 | The main drawbacks to org-mode for me are as follows: 236 | 237 | - Most publishers do not accept org files, but they do accept tex files. (You can export the org file to a LaTeX file that might still need heavy editing of the preamble to get the publisher's acceptance.) 238 | - Overleaf does not support the use of org files. 239 | - Org markup adds another layer of abstraction on top of LaTeX. This layer is thin and not that big of a deal. 240 | 241 | 242 | 243 |

Features of this configuration:

244 | 245 | - Install packages from MELPA with use-package. 246 | - Uses Protesilaos Stavrou's (Prot's) [ef-themes](https://github.com/protesilaos/ef-themes) package. Set to the ef-cyprus theme. The ef-light theme is good too. 247 | - latex-mode and auctex-mode with an old autocompletion package that works, 248 | - Keybindings remapped for macOS so Meta is `cmd`, Super is `cap locks`, and Hyper is `Fn`. 249 | - Numerous keybindings from *outline-mode* to fold and unfold sections in a LaTeX file. 250 | - Configured to cope with the minted package under compiling. It gets around the `compile with -shell-escape` command. 251 | - Configured to use snippets from the *snippets* subfolder. 252 | - Has hippieexpand enabled. 253 | - Uses the *awesome-tabs* package to enable navigation between buffers via tabs. (The keybindings s-0, s-1, ..., s9 enable switching tabs from the keyboard.) 254 | - Has the word count mode (*wc-mode*) enabled. 255 | - Includes pomodoro-mode. 256 | - Has minibuffer history. 257 | - Includes *ivy* enabled for enhanced auto-completion selections. 258 | - *atomic-chrome* configured to interact with *GhostText* extension for Google Chrome so you can edit in Emacs LaTeX documents on Chrome. 259 | - Includes the *texcount* script with `C-c w` to get a more accurate word count when in latex-mode. 260 | - Move N-selected lines up and down with the meta and the arrow keys. 261 | - Scratch buffer retained. 262 | - Add the itemize, enumerate, and description functions to convert selected markdown lists into LaTeX itemize, description, or enumerated lists. 263 | - Includes configuration for changing the size of the font in the modeline. This is useful for preparing slides about using Emacs. 264 | 265 | 266 | ## Installation 267 | 268 | 1. `git clone https://MooersLab/github.com/latex-emacs latex-emacs` in your home directory. 269 | 2. Create link to your snippets folder: `ln -s snippets ~/.emacs.d/snippets`. This link negates the need to maintain multiple copies of the snippet libraries. 270 | 3. Edit file paths in init.el as needed. Git clone the packages stored in manual-packages. 271 | 4. Add `alias e29l='/Applications/Emacs29.0.5.app/Contents/MacOS/Emacs --init-directory ~/latex-emacs29` to your `.bashrc` or `.zshrc` file so you can open Emacs with alias `e29l`. 272 | 5. Add the GhostText extension to Chrome or Firefox or Safari or Edge. 273 | 6. Install LaTeX and include in your PATH. 274 | 7. Edit in `init.el` the file path to texcount. This Perl script comes with LaTeX. You might be able to invoke texcount without the file path if you have no previously defined aliases to do texcount. 275 | 276 | 277 | ## Operation 278 | 279 | This setup can be run in versions > 29.0.5 with `emacs --init-directory ~/latex-emacs29` or the alias `e29l`. 280 | This command ignores your default Emacs configuration in `~/.emacs.d` 281 | You can run it in isolation from your default emacs configuration. 282 | It makes a nice backup system when you break the main configuration. 283 | 284 | Create an empty text file with `touch start.tex`. 285 | Start Emacs and load the file. 286 | Enter `C-o C-e` to create a new document using the corresponding [AUCTeX](https://www.gnu.org/software/auctex/) macro. 287 | 288 | 289 | ## Key bindings 290 | 291 | ### Useful key bindings: LaTeX specific 292 | These keybindings are active in the latex-mode or useful in this mode. 293 | 294 | |Key binding | Description| 295 | |:-----------|:-----------| 296 | |C-c w | Run the texcount script on the buffer. It does not count the words in the LaTeX markup. | 297 | |C-c C-j | Enter at the end of a line for an item in the list. Then a new item is inserted into the next line. | 298 | |M-RET | To insert an item in the middle of the list. | 299 | |C-c C-e | Enter to get a prompt for the kind of environment.| 300 | |C-c C-s | Enter to insert a section or subsection.| 301 | | C-c C-a | Compile and open PDF in the default viewer.| 302 | |C-c C-c | Compile document.| 303 | |C-c ` | Go to compile error.| 304 | |C-c C-p C-s | Preview regions.| 305 | | C-c = | Open the navigable table of contents view of the document. | 306 | |C-c C-k | Kill the text file processing. | 307 | |C-c ; | Comment out a region.| 308 | |C-c % | Comment out a paragraph.| 309 | |C-c C-a | Compile a LaTeX text file and display the PDF in the default PDF viewer.| 310 | |C-j | Add a new line and indent the new line.| 311 | |M-q | To fill in a paragraph (text-wrap) and indent the current paragraph. | 312 | |C-c C-q C-e | Fill and indent the current environment.| 313 | |C-c C-q C-s | Fill and indent the current section.| 314 | |C-c C-q C-r | Fill and indent the current region.| 315 | |C-c { | To insert open and close braces and position the cursor between the braces. | 316 | |C-c } | To move the cursor past the right brace.| 317 | |M-x tex-validate-buffer | Enter to check the entire buffer for syntax errors.| 318 | |M-x tex-validate-region | Enter to check the entire region for syntax errors.| 319 | |C-c C-f | To process a file. | 320 | |C-c C-v | To view a DVI file. | 321 | |C-c C-b | To process the buffer. | 322 | |C-c TAB | To run M-x tex-bibtex-file. | 323 | 324 | 325 | ### Useful key bindings: General editing 326 | 327 | If you are rusty or just starting to use Emacs, you need only these 23 key bindings to function in Emacs. 328 | 329 | |Key binding | Description| 330 | |:-----------|:-----------| 331 | |C-x C-c | Quit Emacs.| 332 | |C-g | Abort current command.| 333 | |C-x C-f | Open a file.| 334 | |M-! | Open a shell, perhaps to create a file to open: touch new.tex.| 335 | |C-SPC | Mark the beginning of a selected region.| 336 | |C-x SPC | Start marking rectangular box selection.| 337 | |C-x u | Undo last command.| 338 | |C-M-_ | Redo undone changes.| 339 | |C-x C-s | Save file.| 340 | |C-x C-w | Save the current buffer to the specified filename.| 341 | |C-y | Paste clipboard. | 342 | |C-w | Cut and store in kill-ring (and clipboard).| 343 | |M-w | Copy to kill-ring (and clipboard). | 344 | |s-c | Copy (option-c). The init.el file above maps the Mac option key to `s`, the Super key.| 345 | |C-k | Delete line and store in kill ring (i.e., clipboard). Repeat to delete the new-line character.| 346 | |C-a | Move the cursor to the beginning of the line.| 347 | |C-e | Move the cursor to the end of the line.| 348 | |C-x d | Open dired for directory navigation.| 349 | |C-h | Invoke the help menu. | 350 | |M-x package-list-packages | Refresh list of packages. Emacs may prompt you to install updates: enter u x y to upgrade packages.| 351 | |M-x package-install | Must run `package-list-packages` first.| 352 | |M-\ | Will join the two words by removing the whitespaces between two words. | 353 | |M-d | Delete word. | 354 | |C-d | Delete character. | 355 | |M-t | Transpose two words when the cursor is in the space between the two words. Useful for editing full names in BibTeX entries.| 356 | 357 | 358 | 359 | Vim users can turn on evil mode to emulate Vim key bindings. 360 | 361 | Uncommenting the corresponding code in the init. el file invokes CUA keybindings (C-c, C-v, and C-x for copy, paste, and cut). 362 | However, there are conflicts with the LaTeX keybindings. 363 | I recommend either using evil-mode or learning the essential Emacs key bindings; they are much easier to master than they look :). 364 | 365 | 366 | ## Quizzes 367 | 368 | The recall of key bindings fades quickly after the first encounter but improves with spaced repetitions. 369 | I have provided two sets of quizzes to improve recall: One set for each set of the above key bindings. 370 | The quizzes in the set have the same questions, but I randomized their order to break up your memory of the answers based on the context of the question in the quiz. 371 | 372 | ## Related projects by Others 373 | 374 | ### Peter Prevos's Emacs Writing Studio (EWS) 375 | 376 | Peter Prevos developed a similar Emacs profile (i.e., init.el file) for academic writing focused on utilizing org-mode for document assembly, citar for bibliography management, and denote for knowledge management. He gave a talk about EWS in December 2025 at the emacsconf. He gave one of the best-organized talks at this conference. Furthermore, he has a playlist of five videos on YouTube about various aspects of deploying EWS. 377 | 378 | He has also written a book about how to utilize EWS. The book is available for purchase as an e-book, but you can compile it via org-mode. Open the top-level org file ./Documents/book/00-emacs-writing-studio.org that imports the book's chapters and other parts. To make a PDF of the book, use the key binding `C-c C-e l o` to export it PDF and open it. 379 | 380 | This book is groundbreaking in several regards. This is the first book about Emacs to discuss modern writing workflows utilizing packages like citar and denote. It is also the first Emacs book I know that is built around an `init.el` file. Hopefully, this book will inspire other authors to write books about their `init.el` files. 381 | 382 | The first 50 pages of this book provide an excellent introduction to Emacs for both coders and writers. The following 100 pages are more focused on the writing process in EWS. The last 50 pages is an Appendix that walks through the init.el file and explains the roles of each of the settings and packages. This is one of the most valuable appendices I have ever read and one of the few I have read in one sitting from beginning to end. 383 | 384 | The book lacks an index, which is surprising because utilizing the LaTeX indexing system inside org-mode is relatively trivial. He might have faced limitations with exporting indices to other publication formats beyond LaTeX. His intent was to make this book available in multiple formats. 385 | 386 | I recommend taking a learning spiral approach to getting started with EWS. I first watched his emacsconf talk. I did not discover his YouTube videos until after I had installed EWS and read his book. If I were to do things over again, I would watch the YouTube videos before reading his book. His book is highly accessible, but I am a poor judge of what a beginner would think because I have been a daily user of Emacs for four years. 387 | 388 | He developed several packages that bring functionality similar to that of org-roam. His citar-denote package integrates the use of citar to assist the generation of literature notes for use in denote. His denote-explore package provides tools for analyzing the distribution of notes across topics and generating directed graphs of links between notes. The first functionality is absent from org-roam. The second functionality mimics the org-roam-ui. These two packages are integrated into his init.el file. These are valuable contributions because Peter has made the denote package attractive to org-roam users and more accessible to academics. 389 | 390 | The denote system of personal knowledge management relies on filenames for information retrieval. It does not utilize a database, like org-roam. The filename has five components. Retrieval of notes and their linking is based on elements of the filename. I find this approach to be very robust to future changes in technology. 391 | 392 | However, assembling a personal Knowledge Management System can be quite a time-sink. Creating forward and backlinks is as time-consuming and tedious as in org-roam. I would not start such a knowledge base if I faced a deadline. 393 | 394 | His profile is meant to be easy to install and requires little customization. You do have to define a few file paths, such as where you will install your denote notes. You will have to wait several minutes while the new packages are installed the first time that you launch Emacs with his init.el file. Emacs will start in 1-2 seconds the second time that you start Emacs with the EWS init.el file. 395 | 396 | I have installed his profile for use with Emacs 30.1. An error message was reported, but it can be safely ignored. The profile works as expected. It uses a beautiful theme that makes working in Emacs more pleasant. I have started using his key bindings for denote and denote-explore. They are pleasant to work with. 397 | 398 | 399 | 400 | 401 | 402 |

My other related projects of possible interest

403 | 404 | - [LaTeX manuscript template](https://github.com/MooersLab/manuscriptInLaTeX/edit/main/README.md) 405 | - [Writing log template in LaTeX](https://github.com/MooersLab/writingLogTemplate) 406 | - [Slideshow template in LaTeX](https://github.com/MooersLab/slideshowTemplateLaTeX) 407 | - [Annotated bibliography Template in LaTeX](https://github.com/MooersLab/annotatedBibliography) 408 | - [My custom elisp functions to make specific tasks easier in Emacs](https://github.com/MooersLab/mooerslab-functions.el) 409 | - [Diary for 2024 in LaTeX](https://github.com/MooersLab/diary2024inLaTeX) 410 | - [Snippets for latex-mode in Emacs](https://github.com/MooersLab/snippet-latex-mode) 411 | - [Quizzes about Emacs to improve recall of keybindings](https://github.com/MooersLab/qemacs) 412 | - [Slides from talk about GhostText, Data Science Workshop, July 2022](https://github.com/MooersLab/DSW22ghosttext) 413 | - [Video link to talk about GhostText, Data Science Workshop, July 2022](https://mediasite.ouhsc.edu/Mediasite/Channel/python/watch/4da0872f028c4255ae12935655e911321d) 414 | - [The writer's law (for stoics)](https://github.com/MooersLab/thewriterslaw) 415 | - [Writing by dictation, suitable for those with repetitive stress injuries](https://github.com/MooersLab#voice-computing) 416 | 417 | ## Funding 418 | - NIH: R01 CA242845, R01 AI088011 419 | - NIH: P30 CA225520 (PI: R. Mannel); P20GM103640 and P30GM145423 (PI: A. West) 420 | 421 | ## Updates 422 | |Version | Changes | Date | 423 | |:-----------:|:-----------------------------------------------------------------------------:|:--------------------:| 424 | | Version 0.2 | Added funding and update table. Minor edits to the README.md | 2024 May 3 | 425 | | Version 0.2.1 | Minor edits in the README.md. | 2024 May 10 | 426 | | Version 0.2.2| More minor edits in the README.md | 2024 June 27 | 427 | | Version 0.2.3| More minor edits in the README.md | 2025 March 4 | 428 | | Version 0.2.4| Added review of EWS to README.md. Updated related links section. | 2025 March 5 | 429 | -------------------------------------------------------------------------------- /emacsQuizEssentials0yr2022mo09day01hr09min01sec59.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/latex-emacs/240fd7e26d482451c6ac7ec44a25301e384565bf/emacsQuizEssentials0yr2022mo09day01hr09min01sec59.pdf -------------------------------------------------------------------------------- /emacsQuizEssentials0yr2022mo09day01hr09min02sec12.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/latex-emacs/240fd7e26d482451c6ac7ec44a25301e384565bf/emacsQuizEssentials0yr2022mo09day01hr09min02sec12.pdf -------------------------------------------------------------------------------- /emacsQuizEssentials0yr2022mo09day01hr09min03sec55.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/latex-emacs/240fd7e26d482451c6ac7ec44a25301e384565bf/emacsQuizEssentials0yr2022mo09day01hr09min03sec55.pdf -------------------------------------------------------------------------------- /emacsQuizEssentials0yr2022mo09day01hr09min04sec24.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/latex-emacs/240fd7e26d482451c6ac7ec44a25301e384565bf/emacsQuizEssentials0yr2022mo09day01hr09min04sec24.pdf -------------------------------------------------------------------------------- /emacsQuizEssentials0yr2022mo09day01hr09min04sec47.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/latex-emacs/240fd7e26d482451c6ac7ec44a25301e384565bf/emacsQuizEssentials0yr2022mo09day01hr09min04sec47.pdf -------------------------------------------------------------------------------- /emacsQuizLatexyr2022mo09day01hr09min05sec27.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/latex-emacs/240fd7e26d482451c6ac7ec44a25301e384565bf/emacsQuizLatexyr2022mo09day01hr09min05sec27.pdf -------------------------------------------------------------------------------- /emacsQuizLatexyr2022mo09day01hr09min06sec05.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/latex-emacs/240fd7e26d482451c6ac7ec44a25301e384565bf/emacsQuizLatexyr2022mo09day01hr09min06sec05.pdf -------------------------------------------------------------------------------- /emacsQuizLatexyr2022mo09day01hr09min06sec22.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/latex-emacs/240fd7e26d482451c6ac7ec44a25301e384565bf/emacsQuizLatexyr2022mo09day01hr09min06sec22.pdf -------------------------------------------------------------------------------- /emacsQuizLatexyr2022mo09day01hr09min06sec50.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/latex-emacs/240fd7e26d482451c6ac7ec44a25301e384565bf/emacsQuizLatexyr2022mo09day01hr09min06sec50.pdf -------------------------------------------------------------------------------- /emacsQuizLatexyr2022mo09day01hr09min07sec07.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MooersLab/latex-emacs/240fd7e26d482451c6ac7ec44a25301e384565bf/emacsQuizLatexyr2022mo09day01hr09min07sec07.pdf -------------------------------------------------------------------------------- /init.el: -------------------------------------------------------------------------------- 1 | ;; ######################################## INSTALL PACKAGES ###################################### 2 | (require 'package) 3 | 4 | (add-to-list 'package-archives 5 | '("melpa" . "http://melpa.org/packages/") t) 6 | (add-to-list 'package-archives 7 | '("melpa-stable" . "https://stable.melpa.org/packages/")) 8 | (add-to-list 'package-archives 9 | '("org" . "http://orgmode.org/elpa/") t) ;; for newest version of org mode 10 | 11 | 12 | (package-initialize) 13 | (when (not package-archive-contents) 14 | (package-refresh-contents)) 15 | 16 | ; Bootstrap `use-package' 17 | (unless (package-installed-p 'use-package) 18 | (package-refresh-contents) 19 | (package-install 'use-package)) 20 | 21 | (unless (package-installed-p `better-defaults) (package-install `better-defaults)) 22 | (unless (package-installed-p `material-theme) (package-install `material-theme)) 23 | (unless (package-installed-p `auto-complete) (package-install `auto-complete)) 24 | 25 | 26 | ;; automate package updating. It is silly to do this manually. 27 | ;; (use-package auto-package-update 28 | ;; :custom 29 | ;; (auto-package-update-interval 31) 30 | ;; (auto-package-update-delete-old-versions t) 31 | ;; (auto-package-update-prompt-before-update t) 32 | ;; (auto-package-update-show-preview t) 33 | ;; :config 34 | ;; (auto-package-update-maybe)) 35 | 36 | ;; ##################################### BASIC CUSTOMIZATION ###################################### 37 | (setq inhibit-startup-message t) ;; hide the startup message 38 | ;; (load-theme 'material t) ;; load material theme 39 | ;; (global-linum-mode t) ;; enable line numbers globally 40 | (set-default 'truncate-lines t) ;; do not wrap 41 | (prefer-coding-system 'utf-8) ;; use UTF-8 42 | 43 | 44 | ;;### Shell configuration 45 | (use-package exec-path-from-shell 46 | :init 47 | (setenv "SHELL" "/bin/zsh") 48 | :ensure t 49 | :if (memq window-system '(mac ns x)) 50 | :config 51 | (setq exec-path-from-shell-variables '("PATH" "GOPATH" "PYTHONPATH")) 52 | (exec-path-from-shell-initialize)) 53 | 54 | 55 | ;;### Faked full screen 56 | (use-package maxframe 57 | :ensure t) 58 | (defvar my-fullscreen-p t "Check if fullscreen is on or off") 59 | (defun my-toggle-fullscreen () 60 | (interactive) 61 | (setq my-fullscreen-p (not my-fullscreen-p)) 62 | (if my-fullscreen-p 63 | (restore-frame) 64 | (maximize-frame))) 65 | ;; (global-set-key (kbd "M-RET") 'toggle-frame-fullscreen) ;; conflicts with an auctex command to insert an \item in a list. 66 | 67 | ;;### Turn on font-locking or syntax highlighting 68 | (global-font-lock-mode t) 69 | 70 | ;;### font size in the modeline 71 | (set-face-attribute 'mode-line nil :height 140) 72 | 73 | ;; set default coding of buffers 74 | (setq default-buffer-file-coding-system 'utf-8-unix) 75 | 76 | ;; Switch from tabs to spaces for indentation 77 | ;; Set the indentation level to 4. 78 | (setq-default indent-tabs-mode nil) 79 | (setq-default tab-width 4) 80 | 81 | 82 | ;;### hippie-expand M-/ 83 | (global-set-key [remap dabbrev-expand] 'hippie-expand) 84 | 85 | 86 | ;; GUI related settings 87 | (if (display-graphic-p) 88 | (progn 89 | ;; Removed some UI elements 90 | ;; (menu-bar-mode -1) 91 | (tool-bar-mode -1) 92 | (scroll-bar-mode -1) 93 | ;; Show battery status 94 | (display-battery-mode 1))) 95 | 96 | 97 | ;; Hey, stop being a whimp and learn the Emacs keybindings! 98 | ;; ;; Set copy+paste 99 | ;; (cua-mode t) 100 | ;; (setq cua-auto-tabify-rectangles nil) ;; Don't tabify after rectangle commands 101 | ;; (transient-mark-mode 1) ;; No region when it is not highlighted 102 | ;; (setq cua-keep-region-after-copy t) ;; Standard Windows behaviour 103 | 104 | ;; REMOVE THE SCRATCH BUFFER AT STARTUP 105 | ;; Makes *scratch* empty. 106 | ;; (setq initial-scratch-message "") 107 | ;; Removes *scratch* from buffer after the mode has been set. 108 | ;; (defun remove-scratch-buffer () 109 | ;; (if (get-buffer "*scratch*") 110 | ;; (kill-buffer "*scratch*"))) 111 | ;; (add-hook 'after-change-major-mode-hook 'remove-scratch-buffer) 112 | 113 | 114 | ;; Disable the C-z sleep/suspend key 115 | ;; See http://stackoverflow.com/questions/28202546/hitting-ctrl-z-in-emacs-freezes-everything 116 | (global-unset-key (kbd "C-z")) 117 | 118 | ;; Disable the C-x C-b key, use helm (C-x b) instead 119 | (global-unset-key (kbd "C-x C-b")) 120 | 121 | 122 | ;; Make copy and paste use the same clipboard as emacs. 123 | (setq select-enable-primary t 124 | select-enable-clipboard t) 125 | 126 | 127 | (setq display-time-default-load-average nil) 128 | (setq display-time-day-and-date t display-time-24hr-format t) 129 | (display-time-mode t) 130 | 131 | 132 | ;; dired-icon-mode 133 | 134 | (add-hook 'dired-mode-hook 'dired-icon-mode) 135 | 136 | ;; replace dired with dirvish 137 | (dirvish-override-dired-mode) 138 | 139 | 140 | ;; Revert Dired and other buffers after changes to files in directories on disk. 141 | ;; Source: [[https://www.youtube.com/watch?v=51eSeqcaikM&list=PLEoMzSkcN8oNmd98m_6FoaJseUsa6QGm2&index=2][Dave Wilson]] 142 | (setq global-auto-revert-non-file-buffers t) 143 | 144 | 145 | ;; customize powerline 146 | ;; (line above the command line at the bottom of the screen) 147 | (use-package powerline 148 | :ensure t) 149 | (require 'powerline) 150 | (powerline-default-theme) 151 | 152 | 153 | ;; Add line numbers. 154 | ;; (global-nlinum-mode t) 155 | 156 | ;; highlight current line 157 | (global-hl-line-mode +1) 158 | (set-face-background hl-line-face "#1c1f26") 159 | (set-face-attribute 'mode-line nil :height 360) 160 | 161 | ;; List recently opened files. 162 | (recentf-mode 1) 163 | 164 | 165 | ;; Revert buffers when the underlying file has changed. 166 | (global-auto-revert-mode 1) 167 | 168 | 169 | ;; Save history going back 25 commands. 170 | ;; Use M-p to get previous command used in the minibuffer. 171 | ;; Use M-n to move to next command. 172 | (setq history-length 25) 173 | (savehist-mode 1) 174 | 175 | 176 | ;; Save place in a file. 177 | (save-place-mode 1) 178 | 179 | 180 | ;; sets monday to be the first day of the week in calendar 181 | (setq calendar-week-start-day 1) 182 | 183 | ;; save emacs backups in a different directory 184 | ;; (some build-systems build automatically all files with a prefix, and .#something.someending breakes that) 185 | (setq backup-directory-alist '(("." . "~/.emacsbackups"))) 186 | 187 | 188 | ;; Enable show-paren-mode (to visualize paranthesis) and make it possible to delete things we have marked 189 | (show-paren-mode 1) 190 | (delete-selection-mode 1) 191 | 192 | 193 | ;; use y or n instead of yes or no 194 | (defalias 'yes-or-no-p 'y-or-n-p) 195 | 196 | ;; These settings enables using the same configuration file on multiple platforms. 197 | ;; Note that windows-nt includes [[https://www.gnu.org/software/emacs/manual/html_node/elisp/System-Environment.html][windows 10]]. 198 | (defconst *is-a-mac* (eq system-type 'darwin)) 199 | (defconst *is-a-linux* (eq system-type 'gnu/linux)) 200 | (defconst *is-windows* (eq system-type 'windows-nt)) 201 | (defconst *is-cygwin* (eq system-type 'cygwin)) 202 | (defconst *is-unix* (not *is-windows*)) 203 | 204 | 205 | ;; See this [[http://ergoemacs.org/emacs/emacs_hyper_super_keys.html][ for more information.]] 206 | ;; set keys for Apple keyboard, for emacs in OS X 207 | ;; Source http://xahlee.info/emacs/emacs/emacs_hyper_super_keys.html 208 | (setq mac-command-modifier 'meta) ; make cmd key do Meta 209 | (setq mac-option-modifier 'super) ; make option key do Super. 210 | (setq mac-control-modifier 'control) ; make Control key do Control 211 | (setq mac-function-modifier 'hyper) ; make Fn key do Hyper. Only works on Apple produced keyboards. 212 | (setq mac-right-command-modifier 'hyper) 213 | 214 | 215 | ;; Switch to previous buffer 216 | (define-key global-map (kbd "s-") 'previous-buffer) 217 | ;; Switch to next buffer 218 | (define-key global-map (kbd "s-") 'next-buffer) 219 | 220 | 221 | ;; Minibuffer history keybindings 222 | ;; The calling up of a previously issued command in the minibuffer with ~M-p~ saves times. 223 | (autoload 'edit-server-maybe-dehtmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) 224 | (autoload 'edit-server-maybe-htmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) 225 | (add-hook 'edit-server-start-hook 'edit-server-maybe-dehtmlize-buffer) 226 | (add-hook 'edit-server-done-hook 'edit-server-maybe-htmlize-buffer) 227 | (define-key minibuffer-local-map (kbd "M-p") 'previous-complete-history-element) 228 | (define-key minibuffer-local-map (kbd "M-n") 'next-complete-history-element) 229 | (define-key minibuffer-local-map (kbd "") 'previous-complete-history-element) 230 | (define-key minibuffer-local-map (kbd "") 'next-complete-history-element) 231 | 232 | 233 | ;; Bibtex configuration 234 | (defconst blaine/bib-libraries (list "/Users/blaine/Documents/global.bib")) 235 | 236 | ;; Combined with emacs-mac, this gives good PDF quality for [[https://www.aidanscannell.com/post/setting-up-an-emacs-playground-on-mac/][retina display]]. 237 | (setq pdf-view-use-scaling t) 238 | 239 | 240 | ;; PDF default page width behavior 241 | (setq-default pdf-view-display-size 'fit-page) 242 | 243 | 244 | ;; Set delay in the matching parenthesis to zero. 245 | (setq show-paren-delay 0) 246 | (show-paren-mode t) 247 | 248 | 249 | ;; rainbow-delimiters 250 | (use-package rainbow-delimiters) 251 | (add-hook 'prog-mode-hook 'rainbow-delimiters-mode) 252 | (set-face-attribute 'rainbow-delimiters-unmatched-face nil 253 | :foreground "magenta" 254 | :inherit 'error 255 | :box t) 256 | 257 | 258 | ;; ############################## Package Configurations ################################ 259 | 260 | ;;## A 261 | 262 | ;;### auto-complete 263 | ;; do default config for auto-complete 264 | (require 'auto-complete) 265 | (require 'auto-complete-config) 266 | (ac-config-default) 267 | (global-auto-complete-mode t) 268 | (ac-flyspell-workaround) 269 | 270 | 271 | 272 | ;;;### auto-complete-auctex.el --- auto-completion for auctex 273 | 274 | ;; Copyright (C) 2012 Christopher Monsanto 275 | 276 | ;; Author: Christopher Monsanto 277 | ;; Version: 1.0 278 | ;; Package-Requires: ((yasnippet "0.6.1") (auto-complete "1.4")) 279 | 280 | ;; This program is free software; you can redistribute it and/or modify 281 | ;; it under the terms of the GNU General Public License as published by 282 | ;; the Free Software Foundation, either version 3 of the License, or 283 | ;; (at your option) any later version. 284 | 285 | ;; This program is distributed in the hope that it will be useful, 286 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 287 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 288 | ;; GNU General Public License for more details. 289 | 290 | ;; You should have received a copy of the GNU General Public License 291 | ;; along with this program. If not, see . 292 | 293 | ;;; Commentary: 294 | 295 | ;; You can install this by (require 'auto-complete-auctex). 296 | ;; Feel free to contribute better documentation! 297 | 298 | ;;;#### Code: 299 | 300 | (require 'tex) 301 | (require 'latex) 302 | 303 | (eval-when-compile 304 | (require 'auto-complete) 305 | (require 'yasnippet)) 306 | 307 | (defvar ac-auctex-arg-lookup-table 308 | '((TeX-arg-define-macro . ("\\MacroName")) 309 | (TeX-arg-counter . ("Counter")) 310 | (TeX-arg-define-counter . ("\\CounterName")) 311 | (TeX-arg-file . ("Filename")) 312 | (TeX-arg-bibliography . ("Filename")) 313 | (TeX-arg-bibstyle . ("Style")) 314 | (TeX-arg-environment . ("Environment")) 315 | (TeX-arg-define-environment . ("EnvironmentName")) 316 | (TeX-arg-size . ("(w, h)")) 317 | (TeX-arg-ref . ("Name")) 318 | (TeX-arg-index . ("Index")) 319 | (TeX-arg-define-label . ("Label")) 320 | (LaTeX-arg-usepackage . (["opt1,..."] "Package")) 321 | (LaTeX-env-label . nil) 322 | (LaTeX-amsmath-env-aligned . (["htbp!"])) 323 | (LaTeX-amsmath-env-alignat . (["# Columns"])) 324 | (LaTeX-env-array . (["bct"] "lcrpmb|")) 325 | (LaTeX-env-item . nil) 326 | (LaTeX-env-document . nil) 327 | (LaTeX-env-figure . (["htbp!"])) 328 | (LaTeX-env-contents . ("Filename")) 329 | (LaTeX-env-minipage . (["htbp!"] "Width")) 330 | (LaTeX-env-list . ("Label" "\\itemsep,\\labelsep,...")) 331 | (LaTeX-env-picture . ("(w, h)" "(x, y)")) 332 | (LaTeX-env-tabular* . ("Width" ["htbp!"] "lcrpmb|><")) 333 | (LaTeX-env-bib . ("WidestLabel")) 334 | (TeX-arg-conditional . ([""])) 335 | (2 . ("" "")) 336 | (3 . ("" "" "")) 337 | (4 . ("" "" "" "")) 338 | (5 . ("" "" "" "" "")) 339 | (6 . ("" "" "" "" "" "")) 340 | (7 . ("" "" "" "" "" "" "")) 341 | (8 . ("" "" "" "" "" "" "" "")) 342 | (9 . ("" "" "" "" "" "" "" "" ""))) 343 | "Anything not in this table defaults to '(\"\")") 344 | 345 | (defun ac-auctex-expand-arg-info (arg-info) 346 | (loop for item in arg-info 347 | append (cond 348 | ((or (stringp item) (and (vectorp item) (stringp (elt item 0)))) 349 | (list item)) 350 | ((vectorp item) 351 | (loop for item-2 in (or (assoc-default (or (car-safe (elt item 0)) (elt item 0)) 352 | ac-auctex-arg-lookup-table 'equal) '("")) 353 | collect [item-2])) 354 | (t 355 | (or (assoc-default (or (car-safe item) item) ac-auctex-arg-lookup-table) '("")))))) 356 | 357 | (defun ac-auctex-snippet-arg (n arg) 358 | (let* ((opt (vectorp arg)) 359 | (item (if opt (elt arg 0) arg)) 360 | (m (if (vectorp arg) (1+ n) n)) 361 | (var (format "${%s}" item))) 362 | (list (1+ m) 363 | (if opt 364 | (concat (format "${[") var "]}") 365 | (concat "{" var "}"))))) 366 | 367 | ;;;#### Macros 368 | ;; 369 | 370 | (defun ac-auctex-expand-args (str env) 371 | (yas/expand-snippet (ac-auctex-macro-snippet (assoc-default str env)))) 372 | 373 | (defun ac-auctex-macro-snippet (arg-info) 374 | (let ((count 1)) 375 | (apply 'concat (loop for item in (ac-auctex-expand-arg-info arg-info) 376 | collect (destructuring-bind (n val) 377 | (ac-auctex-snippet-arg count item) 378 | (setq count n) 379 | val))))) 380 | 381 | (defun ac-auctex-macro-candidates () 382 | (let ((comlist (if TeX-symbol-list 383 | (mapcar (lambda (item) 384 | (or (car-safe (car item)) (car item))) 385 | TeX-symbol-list)))) 386 | (all-completions ac-prefix comlist))) 387 | 388 | (defun ac-auctex-macro-action () 389 | (yas/expand-snippet (ac-auctex-macro-snippet (assoc-default candidate TeX-symbol-list)))) 390 | 391 | (ac-define-source auctex-macros 392 | '((init . TeX-symbol-list) 393 | (candidates . ac-auctex-macro-candidates) 394 | (action . ac-auctex-macro-action) 395 | (requires . 0) 396 | (symbol . "m") 397 | (prefix . "\\\\\\([a-zA-Z]*\\)\\="))) 398 | 399 | ;;;#### Symbols 400 | 401 | (defun ac-auctex-symbol-candidates () 402 | (all-completions ac-prefix (mapcar 'cadr LaTeX-math-default))) 403 | 404 | (defun ac-auctex-symbol-action () 405 | (re-search-backward candidate) 406 | (delete-region (1- (match-beginning 0)) (match-end 0)) 407 | (if (texmathp) 408 | (progn 409 | (insert "\\" candidate) 410 | (yas/expand-snippet (ac-auctex-macro-snippet (assoc-default candidate TeX-symbol-list)))) 411 | (insert "$\\" candidate "$") 412 | (backward-char) 413 | (yas/expand-snippet (ac-auctex-macro-snippet (assoc-default candidate TeX-symbol-list))))) 414 | 415 | (defun ac-auctex-symbol-document (c) 416 | (let* ((cl (assoc c (mapcar 'cdr LaTeX-math-default))) 417 | (decode (if (nth 2 cl) (char-to-string (decode-char 'ucs (nth 2 cl))) "")) 418 | (st (nth 1 cl)) 419 | (hs (if (listp st) (mapconcat 'identity st " ") st))) 420 | (and decode (concat hs " == " decode)))) 421 | 422 | (ac-define-source auctex-symbols 423 | '((init . LaTeX-math-mode) 424 | (candidates . ac-auctex-symbol-candidates) 425 | (document . ac-auctex-symbol-document) 426 | (action . ac-auctex-symbol-action) 427 | (requires . 0) 428 | (symbol . "s") 429 | (prefix . "\\\\\\([a-zA-Z]*\\)\\="))) 430 | 431 | 432 | ;;;#### Environments 433 | 434 | (defvar ac-auctex-environment-prefix "beg") 435 | 436 | (defun ac-auctex-environment-candidates () 437 | (let ((envlist (mapcar (lambda (item) (concat ac-auctex-environment-prefix (car item))) 438 | LaTeX-environment-list))) 439 | (all-completions ac-prefix envlist))) 440 | 441 | (defun ac-auctex-environment-action () 442 | (re-search-backward candidate) 443 | (delete-region (1- (match-beginning 0)) (match-end 0)) 444 | (let ((candidate (substring candidate (length ac-auctex-environment-prefix)))) 445 | (yas/expand-snippet (format "\\begin{%s}%s\n$0\n\\end{%s}" 446 | candidate 447 | (ac-auctex-macro-snippet (assoc-default candidate LaTeX-environment-list)) 448 | candidate)))) 449 | 450 | (ac-define-source auctex-environments 451 | '((init . LaTeX-environment-list) 452 | (candidates . ac-auctex-environment-candidates) 453 | (action . ac-auctex-environment-action) 454 | (requires . 0) 455 | (symbol . "e") 456 | (prefix . "\\\\\\([a-zA-Z]*\\)\\="))) 457 | 458 | 459 | ;;;#### Refs 460 | 461 | (defun ac-auctex-label-candidates () 462 | (all-completions ac-prefix (mapcar 'car LaTeX-label-list))) 463 | 464 | (ac-define-source auctex-labels 465 | '((init . LaTeX-label-list) 466 | (candidates . ac-auctex-label-candidates) 467 | (requires . 0) 468 | (symbol . "r") 469 | (prefix . "\\\\ref{\\([^}]*\\)\\="))) 470 | 471 | 472 | ;;;#### Bibs 473 | 474 | (defun ac-auctex-bib-candidates () 475 | (all-completions ac-prefix (mapcar 'car LaTeX-bibitem-list))) 476 | 477 | (ac-define-source auctex-bibs 478 | `((init . LaTeX-bibitem-list) 479 | (candidates . ac-auctex-bib-candidates) 480 | (requires . 0) 481 | (symbol . "b") 482 | (prefix . ,(concat "\\\\cite" 483 | "\\(?:" 484 | "\\[[^]]*\\]" 485 | "\\)?" 486 | "{\\([^},]*\\)" 487 | "\\=")))) 488 | 489 | ;;;#### Setup 490 | 491 | (defun ac-auctex-setup () 492 | (setq ac-sources (append 493 | '(ac-source-auctex-symbols 494 | ac-source-auctex-macros 495 | ac-source-auctex-environments 496 | ac-source-auctex-labels 497 | ac-source-auctex-bibs) 498 | ac-sources))) 499 | 500 | (add-to-list 'ac-modes 'latex-mode) 501 | (add-hook 'LaTeX-mode-hook 'ac-auctex-setup) 502 | 503 | (provide 'auto-complete-auctex) 504 | 505 | ;;; auto-complete-auctex.el ends here 506 | 507 | ;; indent with spaces instead of tabs for pep8 compatibility 508 | (setq tab-width 4) 509 | (setq-default indent-tabs-mode nil) 510 | 511 | ;; atomic-chrome, used to interact with GhostText extension for Google Chrome. 512 | (use-package atomic-chrome) 513 | (atomic-chrome-start-server) 514 | (setq atomic-chrome-default-major-mode 'python-mode) 515 | (setq atomic-chrome-extension-type-list '(ghost-text)) 516 | ;;(atomic-chrome-start-httpd) 517 | (setq atomic-chrome-server-ghost-text-port 4001) 518 | (setq atomic-chrome-url-major-mode-alist 519 | '(("github\\.com" . gfm-mode) 520 | ("overleaf.com" . latex-mode) 521 | ("750words.com" . latex-mode))) 522 | ; Select the style of opening the editing buffer by atomic-chrome-buffer-open-style. 523 | ; full: Open in the selected window. 524 | ; split: Open in the new window by splitting the selected window (default). 525 | ; frame: Create a new frame and window in it. Must be using some windowing pacakge. 526 | (setq atomic-chrome-buffer-open-style 'split) 527 | 528 | 529 | ;; awesome-tabs 530 | ;; I love awesome-tabs; some people do not. 531 | ;; cd ~/latex-emacs29/manual-packages 532 | ;; git clone --depth=1 https://github.com/manateelazycat/awesome-tab.git 533 | (use-package awesome-tab 534 | :load-path "~/latex-emacs29/manual-packages/awesome-tab" 535 | :config 536 | (awesome-tab-mode t)) 537 | 538 | (global-set-key (kbd "s-1") 'awesome-tab-select-visible-tab) 539 | (global-set-key (kbd "s-2") 'awesome-tab-select-visible-tab) 540 | (global-set-key (kbd "s-3") 'awesome-tab-select-visible-tab) 541 | (global-set-key (kbd "s-4") 'awesome-tab-select-visible-tab) 542 | (global-set-key (kbd "s-5") 'awesome-tab-select-visible-tab) 543 | (global-set-key (kbd "s-6") 'awesome-tab-select-visible-tab) 544 | (global-set-key (kbd "s-7") 'awesome-tab-select-visible-tab) 545 | (global-set-key (kbd "s-8") 'awesome-tab-select-visible-tab) 546 | (global-set-key (kbd "s-9") 'awesome-tab-select-visible-tab) 547 | (global-set-key (kbd "s-0") 'awesome-tab-select-visible-tab) 548 | 549 | 550 | 551 | ;; avy 552 | ;; Navigate buffer after selecting all sites starting with the same one or two letters. 553 | ;; After entering the avy command in the minibuffer, selected sites will be highlighted but they will be indexed with letters. 554 | ;; Enter a letter to go to a desired site. 555 | ;; See https://github.com/abo-abo/avy for documentation. 556 | ;; 557 | 558 | (use-package avy 559 | :ensure t 560 | :bind ("M-s" . avy-goto-char) 561 | ("M-d" . avy-goto-char-2) 562 | ("M-g f" . avy-goto-line) 563 | ("M-g w" . avy-goto-word-1) 564 | ) 565 | 566 | ;;## B 567 | 568 | 569 | ;;### bibtex-mode related 570 | ;; Fetch bibtex for the given DOI. Insert at point, which should be in your global.bib file. 571 | ;; Needs code to reformat the bibtex key. 572 | ;; 573 | ;; https://www.anghyflawn.net/blog/2014/emacs-give-a-doi-get-a-bibtex-entry/ 574 | 575 | (defun get-bibtex-from-doi (doi) 576 | "Get a BibTeX entry from the DOI" 577 | (interactive "MDOI: ") 578 | (let ((url-mime-accept-string "text/bibliography;style=bibtex")) 579 | (with-current-buffer 580 | (url-retrieve-synchronously 581 | (format "http://dx.doi.org/%s" 582 | (replace-regexp-in-string "http://dx.doi.org/" "" doi))) 583 | (switch-to-buffer (current-buffer)) 584 | (goto-char (point-max)) 585 | (setq bibtex-entry 586 | (buffer-substring 587 | (string-match "@" (buffer-string)) 588 | (point))) 589 | (kill-buffer (current-buffer)))) 590 | (insert (decode-coding-string bibtex-entry 'utf-8)) 591 | (define-key bibtex-mode-map (kbd "C-c C-b") 'get-bibtex-from-doi) 592 | (bibtex-fill-entry)) 593 | ;; I want run the above function to define it upon entry into a Bibtex file. 594 | (add-hook 595 | 'bibtex-mode-hook 596 | (lambda () 597 | (get-bibtex-from-doi nil))) 598 | 599 | ;; Hook to add imenu to menubar in bibtex mode 600 | ;; http://www.jonathanleroux.org/bibtex-mode.html 601 | (add-hook 602 | 'bibtex-mode-hook 603 | (lambda () 604 | (imenu-add-to-menubar "Imenu"))) 605 | 606 | ;; Fetch bibtex information from DOI. 607 | ;; Source https://chainsawriot.com/postmannheim/2022/12/13/aoe13.html 608 | ;; Copy the DOI from Firefox (or any source) 609 | ;; 1. Go back to emacs (By C . e) 610 | ;; 2. Run the custom command: M-x add-doi and paste yank the DOI (C-y) 611 | ;; 3. Auto: Fetch the BIBTEX 612 | ;; 4. from Crossref 613 | ;; 5. Auto: Add it into “~/dev/dotfiles/bib.bib” 614 | ;; 6. Save it 615 | (defun add-doi () 616 | (interactive) 617 | (progn 618 | (setq doi-to-query (read-string "DOI ")) 619 | (find-file "~/Documents/global.bib") 620 | (end-of-buffer) 621 | (doi-insert-bibtex doi-to-query) 622 | ) 623 | ) 624 | 625 | (use-package biblio 626 | :config 627 | (setq-default 628 | biblio-bibtex-use-autokey t 629 | bibtex-autokey-name-year-separator "" 630 | bibtex-autokey-year-title-separator "" 631 | bibtex-autokey-year-length 4 632 | bibtex-autokey-titlewords 7 633 | bibtex-autokey-titleword-length -1 ;; -1 means exactly one 634 | bibtex-autokey-titlewords-stretch 0 635 | bibtex-autokey-titleword-separator "" 636 | bibtex-autokey-titleword-case-convert 'upcase) 637 | ) 638 | 639 | 640 | 641 | 642 | 643 | 644 | ;; ** D 645 | 646 | ;; Getting pretty icons 647 | (use-package all-the-icons) 648 | 649 | (use-package dashboard 650 | ;; :after (all-the-icons dashboard-hackernews helm-system-packages) 651 | :ensure t 652 | :init 653 | (dashboard-setup-startup-hook) 654 | 655 | :custom 656 | (dashboard-banner-logo-title "Let's get stuff done!") 657 | (dashboard-startup-banner 'logo) 658 | (dashboard-center-content t) 659 | (dashboard-set-navigator t) 660 | ;; (dashboard-navigator-buttons '((("⤓" " Install system package" " Install system package" (lambda (&rest _) (helm-system-packages)))))) 661 | (dashboard-set-heading-icons t) 662 | (dashboard-set-file-icons t) 663 | (dashboard-items '((projects . 10) 664 | (recents . 15) 665 | (hackernews . 5)))) 666 | 667 | 668 | (use-package dashboard-hackernews 669 | :ensure t) 670 | 671 | 672 | 673 | ;;# ** Dired related 674 | (use-package dired-subtree :ensure t 675 | :after dired 676 | :config 677 | (bind-key "" #'dired-subtree-toggle dired-mode-map) 678 | (bind-key "" #'dired-subtree-cycle dired-mode-map)) 679 | 680 | 681 | ;; ** E 682 | 683 | ;; *** ef-theme 684 | 685 | (use-package ef-themes 686 | :ensure t) 687 | ;; If you like two specific themes and want to switch between them, you 688 | ;; can specify them in `ef-themes-to-toggle' and then invoke the command 689 | ;; `ef-themes-toggle'. All the themes are included in the variable 690 | ;; `ef-themes-collection'. 691 | (setq ef-themes-to-toggle '(ef-summer ef-winter)) 692 | 693 | ;; Make customisations that affect Emacs faces BEFORE loading a theme 694 | ;; (any change needs a theme re-load to take effect). 695 | 696 | (setq ef-themes-headings ; read the manual's entry or the doc string 697 | '((0 . (variable-pitch light 1.9)) 698 | (1 . (variable-pitch light 1.8)) 699 | (2 . (variable-pitch regular 1.7)) 700 | (3 . (variable-pitch regular 1.6)) 701 | (4 . (variable-pitch regular 1.5)) 702 | (5 . (variable-pitch 1.4)) ; absence of weight means `bold' 703 | (6 . (variable-pitch 1.3)) 704 | (7 . (variable-pitch 1.2)) 705 | (t . (variable-pitch 1.1)))) 706 | 707 | ;; They are nil by default... 708 | (setq ef-themes-mixed-fonts t 709 | ef-themes-variable-pitch-ui t) 710 | 711 | ;; Disable all other themes to avoid awkward blending: 712 | (mapc #'disable-theme custom-enabled-themes) 713 | 714 | ;; Load the theme of choice: 715 | (load-theme 'ef-cyprus :no-confirm) 716 | 717 | ;; The themes we provide: 718 | ;; 719 | ;; Light: `ef-day', `ef-light', `ef-spring', `ef-summer'. 720 | ;; Dark: `ef-autumn', `ef-dark', `ef-night', `ef-winter'. 721 | ;; 722 | ;; Also those which are optimized for deuteranopia (red-green color 723 | ;; deficiency): `ef-deuteranopia-dark', `ef-deuteranopia-light'. 724 | 725 | ;; We also provide these commands, but do not assign them to any key: 726 | ;; 727 | ;; - `ef-themes-toggle' 728 | ;; - `ef-themes-select' 729 | ;; - `ef-themes-load-random' 730 | ;; - `ef-themes-preview-colors' 731 | ;; - `ef-themes-preview-colors-current'#+END_SRC 732 | 733 | 734 | 735 | ;; *** Electric-pair mode. Add matching pairs of quotes and parentheses. 736 | (electric-pair-mode) 737 | 738 | 739 | ;; *** electric-spacing 740 | ;; An emacs minor-mode to automatically add spacing around [[https://github.com/xwl/electric-spacing][operators] in math expressions.]. 741 | ;; Backspace over the whitespaces to remove them when none are permitted. 742 | (use-package electric-spacing 743 | :ensure t) 744 | 745 | ;; git clone https://github.com/walmes/electric-spacing.git into ~/latex-emacs29/manual-packages 746 | ;; byte-compile with (byte-compile-file "~/latex-emacs29/manual-packages/electric-spacing/electric-spacing.el") 747 | ;; byte-compile with (byte-compile-file "~/latex-emacs29/manual-packages/electric-spacing/electric-spacing-r.el") 748 | (add-to-list 'load-path "~/latex-emacs29/manual-packages/electric-spacing") 749 | (require 'electric-spacing-r) 750 | (add-hook 'ess-mode-hook #'electric-spacing-mode) 751 | ;; restrict to limited number of modes to keep it out of the minibuffer 752 | (defvar my-electic-pair-modes '(python-mode julia-mode org-mode latex-mode)) 753 | (defun my-inhibit-electric-pair-mode (char) 754 | (not (member major-mode my-electic-pair-modes))) 755 | (setq electric-pair-inhibit-predicate #'my-inhibit-electric-pair-mode) 756 | 757 | 758 | ;; *** Emojis 759 | (use-package emojify 760 | :init 761 | (add-hook 'after-init-hook #'global-emojify-mode)) 762 | 763 | 764 | ;; ** F 765 | 766 | 767 | ;; *** FlySpell (spell checking) 768 | (dolist (flyspellmodes '(text-mode-hook 769 | org-mode-hook 770 | latex-mode-hook)) 771 | (add-hook flyspellmodes 'turn-on-flyspell)) 772 | 773 | ;; comments and strings in code 774 | (add-hook 'prog-mode-hook 'flyspell-prog-mode) 775 | 776 | ;; sets american english as defult 777 | (setq ispell-dictionary "american") 778 | 779 | ;; let us cycle american english (best written english) and norwegian 780 | (defun change-dictionary () 781 | (interactive) 782 | (ispell-change-dictionary (if (string-equal ispell-current-dictionary "american") 783 | "norsk" 784 | "american"))) 785 | 786 | ;; helm functionality for flyspell. To make it more user friendly 787 | ;; (use-package helm-flyspell 788 | ;; :after flyspell 789 | ;; :init 790 | ;; ;; Disable standard keys for flyspell correct, and make my own for helm. 791 | ;; (define-key flyspell-mode-map (kbd "C-.") nil) 792 | ;; (define-key flyspell-mode-map (kbd "C-,") #'helm-flyspell-correct)) 793 | 794 | 795 | ;; *** Focus 796 | ;; Highlights the current section or function. 797 | (use-package focus) 798 | 799 | ;; ** G 800 | 801 | 802 | 803 | 804 | 805 | ;; ** H 806 | ;; *** Helm 807 | ;; Use ivy or helm but not both. 808 | ;; (use-package helm 809 | ;; :after (projectile helm-projectile) 810 | ;; 811 | ;; :init 812 | ;; (helm-mode 1) 813 | ;; (projectile-mode +1) 814 | ;; (helm-projectile-on) 815 | ;; (helm-adaptive-mode 1) 816 | ;; ;; hide uninteresting buffers from buffer list 817 | ;; (add-to-list 'helm-boring-buffer-regexp-list (rx "magit-")) 818 | ;; (add-to-list 'helm-boring-buffer-regexp-list (rx "*helm")) 819 | ;; 820 | ;; :custom 821 | ;; (helm-M-x-fuzzy-match t) 822 | ;; (projectile-completion-system 'helm) 823 | ;; (helm-split-window-in-side-p t) 824 | ;; 825 | ;; :bind 826 | ;; (("M-x" . helm-M-x) 827 | ;; ("C-x C-f" . helm-find-files) 828 | ;; ;; get the awesome buffer list instead of the standard stuff 829 | ;; ("C-x b" . helm-mini))) 830 | ;; 831 | ;;;; *** helm-system-packages 832 | ;;;;(use-package helm-system-packages 833 | ;;;; :after helm) 834 | ;; 835 | ;;;; *** Helm-bibtex 836 | ;;;; Can only use helm-bitex or ivy-bibtex 837 | ;;;; See https://github.com/tmalsburg/helm-bibtex for extensive documentation and configuration. 838 | ;;(use-package helm-bibtex 839 | ;; :ensure t 840 | ;; :config 841 | ;; (setq bibtex-completion-library-path '("~/0labeledPapers" "~/0bookaLabeled")) 842 | ;; (setq bibtex-completion-pdf-field "File") 843 | ;; (setq bibtex-completion-notes-path '("~/0labeledPapers/notes" "~/0papersLabeled/notes")) 844 | ;; (setq org-cite-follow-processor 'helm-bibtex-org-cite-follow) 845 | ;; (setq bibtex-completion-display-formats 846 | ;; '((article . "${=has-pdf=:1}${=has-note=:1} ${=type=:3} ${year:4} ${author:36} ${title:*} ${journal:40}") 847 | ;; (inbook . "${=has-pdf=:1}${=has-note=:1} ${=type=:3} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}") 848 | ;; (incollection . "${=has-pdf=:1}${=has-note=:1} ${=type=:3} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 849 | ;; (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${=type=:3} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 850 | ;; (t . "${=has-pdf=:1}${=has-note=:1} ${=type=:3} ${year:4} ${author:36} ${title:*}"))) 851 | ;; (setq bibtex-completion-additional-search-fields '(keywords)) 852 | ;; (setq bibtex-completion-pdf-symbol "⌘") 853 | ;; (setq bibtex-completion-notes-symbol "✎") 854 | ;; (setq bibtex-completion-pdf-open-function 855 | ;; (lambda (fpath) 856 | ;; (call-process "open" nil 0 nil "-a" "/Applications/Skim.app" fpath))) 857 | ;; (setq bibtex-completion-find-additional-pdfs t) 858 | ;; (setq bibtex-completion-browser-function 859 | ;; (lambda (url _) (start-process "firefox" "*firefox*" "firefox" url))) 860 | ;; (setq bibtex-completion-format-citation-functions 861 | ;; '((org-mode . bibtex-completion-format-citation-org-title-link-to-PDF) 862 | ;; (latex-mode . bibtex-completion-format-citation-cite) 863 | ;; (markdown-mode . bibtex-completion-format-citation-pandoc-citeproc) 864 | ;; (default . bibtex-completion-format-citation-default))) 865 | ;; (setq bibtex-completion-additional-search-fields '(tags)) 866 | ;;) 867 | ;; 868 | ;;;; (require 'helm-config) 869 | ;;;; 870 | ;;(global-set-key (kbd "") 'helm-command-prefix) 871 | ;; 872 | ;;(define-key helm-command-map "b" 'helm-bibtex) 873 | ;;(define-key helm-command-map "B" 'helm-bibtex-with-local-bibliography) 874 | ;;(define-key helm-command-map "n" 'helm-bibtex-with-notes) 875 | ;;(define-key helm-command-map (kbd "") 'helm-resume) 876 | ;; 877 | ;;(defun helm-bibtex-my-publications (&optional arg) 878 | ;; "Search BibTeX entries authored by “Blaine Mooers”. 879 | ;; 880 | ;;With a prefix ARG, the cache is invalidated and the bibliography reread." 881 | ;; (interactive "P") 882 | ;; (helm-bibtex arg nil "Blaine Mooers")) 883 | ;; 884 | ;;;; Bind this search function to Ctrl-x p: 885 | ;;(global-set-key (kbd "C-x p") 'helm-bibtex-my-publications) 886 | ;; 887 | ;;;; 888 | ;;(helm-add-action-to-source 889 | ;; "Open annotated PDF (if present)" 'helm-bibtex-open-annotated-pdf 890 | ;; helm-source-bibtex 1) 891 | ;; 892 | ;;(helm-delete-action-from-source "Insert BibTeX key" helm-source-bibtex) 893 | ;;(helm-add-action-to-source "Insert BibTeX key" 'helm-bibtex-insert-key helm-source-bibtex 0) 894 | ;; 895 | ;;(helm-bibtex-helmify-action bibtex-completion- helm-bibtex-) 896 | ;; 897 | ;;;; (setq tmalsburg-pdf-watch 898 | ;;;; (file-notify-add-watch bibtex-completion-library-path 899 | ;;;; '(change) 900 | ;;;; (lambda (event) (bibtex-completion-candidates)))) 901 | ;; 902 | 903 | 904 | ;; ** I 905 | 906 | ;; 907 | 908 | ;; *** ivy 909 | ;; Use ivy or helm but not both. 910 | (use-package ivy 911 | :ensure t 912 | :init 913 | (ivy-mode 1) 914 | (global-set-key "\C-s" 'swiper) 915 | (unbind-key "S-SPC" ivy-minibuffer-map) 916 | (setq ivy-height 15 917 | ivy-use-virtual-buffers t 918 | ivy-count-format "(%d/%d) " 919 | ivy-use-selectable-prompt t)) 920 | (use-package ivy-bibtex 921 | :ensure t) 922 | 923 | 924 | 925 | ;;## L 926 | 927 | 928 | ;;### LanguageTool 929 | 930 | ;; I downloaded Language Tool and installed it in ~/.languagetool. 931 | ;; source: https://github.com/PillFall/languagetool.el 932 | 933 | 934 | (use-package languagetool 935 | :ensure t 936 | :defer t 937 | :commands (languagetool-check 938 | languagetool-clear-suggestions 939 | languagetool-correct-at-point 940 | languagetool-correct-buffer 941 | languagetool-set-language 942 | languagetool-server-mode 943 | languagetool-server-start 944 | languagetool-server-stop) 945 | :config 946 | (setq languagetool-java-arguments '("-Dfile.encoding=UTF-8") 947 | languagetool-console-command "~/.languagetool/languagetool-commandline.jar" 948 | languagetool-server-command "~/.languagetool/languagetool-server.jar")) 949 | 950 | (setq languagetool-java-arguments '("-Dfile.encoding=UTF-8")) 951 | 952 | (setq languagetool-console-command "~/.languagetool/languagetool-commandline.jar" 953 | languagetool-server-command "~/.languagetool/languagetool-server.jar") 954 | 955 | ;;### LaTeX helpher functions 956 | ;;#### M-x description 957 | ;; Converts a selected list into a description list. 958 | ;; The elements of the list must begin with a dash. 959 | ;; The terms to be inserted into the square brackets 960 | ;; have to be added after running the function. 961 | (defun description (beg end) 962 | "wrap the active region in an 'itemize' environment, 963 | converting hyphens at the beginning of a line to \item" 964 | (interactive "r") 965 | (save-restriction 966 | (narrow-to-region beg end) 967 | (beginning-of-buffer) 968 | (insert "\\begin{description}\n") 969 | (while (re-search-forward "^- " nil t) 970 | (replace-match "\\\\item[ ]")) 971 | (end-of-buffer) 972 | (insert "\\end{description}\n"))) 973 | 974 | 975 | ;;#### M-x enumerate 976 | ;; Converts a selected list into an enumerated list. 977 | ;; The elements of the list must begin with a dash. 978 | (defun enumerate (beg end) 979 | "wrap the active region in an 'itemize' environment, 980 | converting hyphens at the beginning of a line to \item" 981 | (interactive "r") 982 | (save-restriction 983 | (narrow-to-region beg end) 984 | (beginning-of-buffer) 985 | (insert "\\begin{enumerate}\n") 986 | (while (re-search-forward "^- " nil t) 987 | (replace-match "\\\\item ")) 988 | (end-of-buffer) 989 | (insert "\\end{enumerate}\n"))) 990 | 991 | 992 | ;;#### M-x itemize 993 | ;; Converts a selected list into an itemized list. 994 | ;; The elements of the list must begin with a dash. 995 | ;; A similar function could be made to make an enumerated list 996 | ;; and a description list. 997 | ;; Source: \url{https://tex.stackexchange.com/questions/118958/emacsauctex-prevent-region-filling-when-inserting-itemize} 998 | (defun itemize (beg end) 999 | "wrap the active region in an 'itemize' environment, 1000 | converting hyphens at the beginning of a line to \item" 1001 | (interactive "r") 1002 | (save-restriction 1003 | (narrow-to-region beg end) 1004 | (beginning-of-buffer) 1005 | (insert "\\begin{itemize}\n") 1006 | (while (re-search-forward "^- " nil t) 1007 | (replace-match "\\\\item ")) 1008 | (end-of-buffer) 1009 | (insert "\\end{itemize}\n"))) 1010 | 1011 | 1012 | ;;#### LaTeX related 1013 | (unless (package-installed-p `auctex) (package-install `auctex)) 1014 | 1015 | (setq TeX-auto-save t) 1016 | (setq TeX-parse-self t) 1017 | (setq-default TeX-master nil) 1018 | (add-hook 'LaTeX-mode-hook 'visual-line-mode) 1019 | (add-hook 'LaTeX-mode-hook 'flyspell-mode) 1020 | (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode) 1021 | (add-hook 'LaTeX-mode-hook 'turn-on-reftex) 1022 | (setq reftex-plug-into-AUCTeX t) 1023 | 1024 | (setq doc-view-continuous t) ;; scroll over all pages in doc view 1025 | 1026 | ;; Settings for minted package issue 1027 | (eval-after-load "tex" 1028 | '(setcdr (assoc "LaTeX" TeX-command-list) 1029 | '("%`%l%(mode) -shell-escape%' %t" 1030 | TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX") 1031 | ) 1032 | ) 1033 | 1034 | ;; Outline-minor-mode key map Source: https://www.emacswiki.org/emacs/OutlineMinorMode 1035 | (define-prefix-command 'cm-map nil "Outline-") 1036 | ; HIDE 1037 | (define-key cm-map "q" 'hide-sublevels) ; Hide everything but the top-level headings 1038 | (define-key cm-map "t" 'hide-body) ; Hide everything but headings (all body lines) 1039 | (define-key cm-map "o" 'hide-other) ; Hide other branches 1040 | (define-key cm-map "c" 'hide-entry) ; Hide this entry's body 1041 | (define-key cm-map "l" 'hide-leaves) ; Hide body lines in this entry and sub-entries 1042 | (define-key cm-map "d" 'hide-subtree) ; Hide everything in this entry and sub-entries 1043 | ;; SHOW 1044 | (define-key cm-map "a" 'show-all) ; Show (expand) everything 1045 | (define-key cm-map "e" 'show-entry) ; Show this heading's body 1046 | (define-key cm-map "i" 'show-children) ; Show this heading's immediate child sub-headings 1047 | (define-key cm-map "k" 'show-branches) ; Show all sub-headings under this heading 1048 | (define-key cm-map "s" 'show-subtree) ; Show (expand) everything in this heading & below 1049 | ;; MOVE 1050 | (define-key cm-map "u" 'outline-up-heading) ; Up 1051 | (define-key cm-map "n" 'outline-next-visible-heading) ; Next 1052 | (define-key cm-map "p" 'outline-previous-visible-heading) ; Previous 1053 | (define-key cm-map "f" 'outline-forward-same-level) ; Forward - same level 1054 | (define-key cm-map "b" 'outline-backward-same-level) ; Backward - same level 1055 | (global-set-key "\M-o" cm-map) 1056 | 1057 | 1058 | ;; Increase size of LaTeX fragment previews in org files 1059 | ;; (plist-put org-format-latex-options :scale 2) 1060 | 1061 | 1062 | 1063 | ;; ## nlinum for line numbers 1064 | ;; (global-nlinum-mode t) 1065 | 1066 | 1067 | ;; *** LSP = Language Server Protocol 1068 | ;; lsp-mode uses LSP servers to provides IDE functionality like code completion 1069 | ;; (intellisense like using company-capf), navigation (jump to symbol), 1070 | ;; refactoring functionality and so on. lsp-ui is used to get prettier boxes and 1071 | ;; more info visible in an easy way (like javadoc). 1072 | ;; Currently dap-mode is added because I play a bit with it, 1073 | ;; and my first impressions are great so far 1074 | ;; (for the few times I use a debugger, I know I’m weird for not needing it much at all). 1075 | 1076 | (use-package lsp-mode 1077 | :bind 1078 | ("M-RET" . lsp-execute-code-action)) 1079 | 1080 | ;; helper boxes and other nice functionality (like javadoc for java) 1081 | (defun lsp-ui-show-doc-helper () 1082 | (interactive) 1083 | (if (lsp-ui-doc--visible-p) 1084 | (lsp-ui-doc-hide) 1085 | (lsp-ui-doc-show))) 1086 | 1087 | (use-package lsp-ui 1088 | :after lsp-mode 1089 | :custom 1090 | (lsp-ui-sideline-show-code-actions t) 1091 | (lsp-ui-doc-position 'at-point) 1092 | :bind 1093 | ("M-s M-d" . lsp-ui-show-doc-helper)) 1094 | 1095 | ;; Additional helpers using treemacs 1096 | ;; (symbols view, errors, dependencies for Java etc.) 1097 | (use-package lsp-treemacs 1098 | :after lsp-mode 1099 | :config 1100 | (lsp-treemacs-sync-mode 1)) 1101 | 1102 | ;; debugger component (for the few times I need it) 1103 | (use-package dap-mode 1104 | :after lsp-mode 1105 | :init 1106 | (dap-auto-configure-mode)) 1107 | 1108 | (use-package flycheck 1109 | :custom 1110 | (flycheck-indication-mode nil) 1111 | (flycheck-highlighting-mode 'lines)) 1112 | 1113 | 1114 | ;; ** M 1115 | ;; *** magit 1116 | (use-package magit 1117 | :commands magit-status 1118 | :bind 1119 | ("C-x g" . magit-status)) 1120 | 1121 | ;; show todos in magit status buffer 1122 | (use-package magit-todos 1123 | :after (magit) 1124 | :hook 1125 | (magit-status-mode . magit-todos-mode) 1126 | ) 1127 | 1128 | (use-package git-gutter 1129 | :ensure git-gutter-fringe 1130 | :after magit 1131 | :init 1132 | (global-git-gutter-mode 1) 1133 | (setq-default left-fringe-width 20) 1134 | :hook 1135 | (magit-post-refresh . git-gutter:update-all-windows)) 1136 | 1137 | ;; *** Configured for GitHub Markdown 1138 | (use-package markdown-mode 1139 | :ensure t 1140 | :mode ("\\.md\\'" . gfm-mode) 1141 | :commands (markdown-mode gfm-mode) 1142 | :config 1143 | (setq markdown-command "pandoc -t html5")) 1144 | ;;Install simple-httpd and impatient-mode packages. 1145 | (use-package simple-httpd 1146 | :ensure t 1147 | :config 1148 | (setq httpd-port 7070) 1149 | (setq httpd-host (system-name))) 1150 | ;; The impatient-mode package takes the content of your buffer, passes it through a filter, and serves the result via simple-httpd HTTP server. 1151 | (use-package impatient-mode 1152 | :ensure t 1153 | :commands impatient-mode) 1154 | ;; Create a filter function to process the Markdown buffer. 1155 | ;; The function my-markdown-filter uses github-markdown-css to mimic the look of GitHub. 1156 | (defun my-markdown-filter (buffer) 1157 | (princ 1158 | (with-temp-buffer 1159 | (let ((tmp (buffer-name))) 1160 | (set-buffer buffer) 1161 | (set-buffer (markdown tmp)) 1162 | (format "Markdown preview 1163 |
%s
" (buffer-string)))) 1164 | (current-buffer))) 1165 | ;; Create the function my-markdown-preview to show the preview. 1166 | (defun my-markdown-preview () 1167 | "Preview markdown." 1168 | (interactive) 1169 | (unless (process-status "httpd") 1170 | (httpd-start)) 1171 | (impatient-mode) 1172 | (imp-set-user-filter 'my-markdown-filter) 1173 | (imp-visit-buffer)) 1174 | ;; Run my-markdown-preview in any Markdown buffer. 1175 | ;; It will open a new window in your browser and update it as you type. 1176 | 1177 | 1178 | ;; ;; Let's try an org-mode previewer 1179 | ;; (require 'org-mode 1180 | ;; :mode ("\\.org\\'" . gfm-mode) 1181 | ;; :commands (org-mode gfm-mode) 1182 | ;; :config 1183 | ;; (setq org-command "pandoc -t html5")) 1184 | ;; 1185 | ;; (defun my-org-filter (buffer) 1186 | ;; (princ 1187 | ;; (with-temp-buffer 1188 | ;; (let ((tmp (buffer-name))) 1189 | ;; (set-buffer buffer) 1190 | ;; (set-buffer (org tmp)) 1191 | ;; (format "Markdown preview 1192 | ;;
%s
" (buffer-string)))) 1193 | ;; (current-buffer))) 1194 | ;; ;; Create the function my-org-preview to show the preview. 1195 | ;; 1196 | ;; (defun my-org-preview () 1197 | ;; "Preview org." 1198 | ;; (interactive) 1199 | ;; (unless (process-status "httpd") 1200 | ;; (httpd-start)) 1201 | ;; (impatient-mode) 1202 | ;; (imp-set-user-filter 'my-og-filter) 1203 | ;; (imp-visit-buffer)) 1204 | 1205 | 1206 | ;;### Move selected regions up or down 1207 | ;; It is commands like these one that enable rapid reorganization of your prose when writing one sentence per row. 1208 | ;; Thank you to DivineDomain for the suggested upgrade. 1209 | ;; Source: https://www.emacswiki.org/emacs/MoveText 1210 | (defun move-text-internal (arg) 1211 | (cond 1212 | ((and mark-active transient-mark-mode) 1213 | (if (> (point) (mark)) 1214 | (exchange-point-and-mark)) 1215 | (let ((column (current-column)) 1216 | (text (delete-and-extract-region (point) (mark)))) 1217 | (forward-line arg) 1218 | (move-to-column column t) 1219 | (set-mark (point)) 1220 | (insert text) 1221 | (exchange-point-and-mark) 1222 | (setq deactivate-mark nil))) 1223 | (t 1224 | (let ((column (current-column))) 1225 | (beginning-of-line) 1226 | (when (or (> arg 0) (not (bobp))) 1227 | (forward-line) 1228 | (when (or (< arg 0) (not (eobp))) 1229 | (transpose-lines arg)) 1230 | (forward-line -1)) 1231 | (move-to-column column t))))) 1232 | 1233 | (defun move-line-region-down (arg) 1234 | "Move region (transient-mark-mode active) or current line 1235 | arg lines down." 1236 | (interactive "*p") 1237 | (move-text-internal arg)) 1238 | 1239 | (defun move-line-region-up (arg) 1240 | "Move region (transient-mark-mode active) or current line 1241 | arg lines up." 1242 | (interactive "*p") 1243 | (move-text-internal (- arg))) 1244 | 1245 | (global-set-key (kbd "M-") 'move-line-region-down) 1246 | (global-set-key (kbd "M-") 'move-line-region-up) 1247 | 1248 | 1249 | 1250 | ;; ;;### Move lines up an down 1251 | ;; It is commands like these one that enable rapid reorganization of your prose when writing one sentence per row. 1252 | ;; Retained for those who have not mastered regions. 1253 | ;; (defun move-line (n) 1254 | ;; "Move the current line up or down by N lines." 1255 | ;; (interactive "p") 1256 | ;; (setq col (current-column)) 1257 | ;; (beginning-of-line) (setq start (point)) 1258 | ;; (end-of-line) (forward-char) (setq end (point)) 1259 | ;; (let ((line-text (delete-and-extract-region start end))) 1260 | ;; (forward-line n) 1261 | ;; (insert line-text) 1262 | ;; ;; restore point to original column in moved line 1263 | ;; (forward-line -1) 1264 | ;; (forward-char col))) 1265 | 1266 | ;; (defun move-line-up (n) 1267 | ;; "Move the current line up by N lines." 1268 | ;; (interactive "p") 1269 | ;; (move-line (if (null n) -1 (- n)))) 1270 | 1271 | ;; (defun move-line-down (n) 1272 | ;; "Move the current line down by N lines." 1273 | ;; (interactive "p") 1274 | ;; (move-line (if (null n) 1 n))) 1275 | 1276 | ;; (global-set-key (kbd "M-") 'move-line-up) 1277 | ;; (global-set-key (kbd "M-") 'move-line-down) 1278 | 1279 | ;; Sometimes we want to edit multiple places in the file at the same time. 1280 | ;; Most of the time this is just adding the same characters multiple places 1281 | ;; in the file in places with the same pattern, 1282 | ;; other times it is inserting a sequence of numbers. 1283 | 1284 | (use-package multiple-cursors 1285 | :bind 1286 | ("C->" . mc/mark-next-like-this)) 1287 | 1288 | 1289 | ;; ** O 1290 | 1291 | ;; *** Olivetti 1292 | ;; Improves readability. 1293 | ;; Olivetti centers the entire buffer like a sheet 1294 | ;; of paper and truncates the content. 1295 | ;; This helps my eyes when writing things that are 1296 | ;; more natural flowing text (articles, books, other org mode stuff). 1297 | 1298 | (use-package olivetti 1299 | :if window-system 1300 | :after org 1301 | :custom 1302 | (olivetti-minimum-body-width 100) 1303 | (olivetti-body-width 0.8) 1304 | :hook 1305 | (org-mode . olivetti-mode)) 1306 | 1307 | 1308 | ;; <<<<<<< BEGINNING of org-agenda >>>>>>>>>>>>>> 1309 | (setq org-agenda-start-with-log-mode t) 1310 | (setq org-log-done 'time) 1311 | (setq org-log-into-drawer t) 1312 | 1313 | (define-key global-map "\C-ca" 'org-agenda) 1314 | (setq org-log-done t) 1315 | ;; org-capture 1316 | (define-key global-map "\C-cc" 'org-capture) 1317 | (define-key global-map "\C-cl" 'org-store-link) 1318 | 1319 | (setq org-columns-default-format "%50ITEM(Task) %10CLOCKSUM %16TIMESTAMP_IA") 1320 | 1321 | (setq org-agenda-files '("/Users/blaine/gtd/tasks/JournalArticles.org" 1322 | "/Users/blaine/gtd/tasks/Proposals.org" 1323 | "/Users/blaine/gtd/tasks/Books.org" 1324 | "/Users/blaine/gtd/tasks/Talks.org" 1325 | "/Users/blaine/gtd/tasks/Posters.org" 1326 | "/Users/blaine/gtd/tasks/ManuscriptReviews.org" 1327 | "/Users/blaine/gtd/tasks/Private.org" 1328 | "/Users/blaine/gtd/tasks/Service.org" 1329 | "/Users/blaine/gtd/tasks/Teaching.org" 1330 | "/Users/blaine/gtd/tasks/Workshops.org" 1331 | "/Users/blaine/gtd/tasks/grasscatchers.org")) 1332 | 1333 | ;; Cycle through these keywords with shift right or left arrows. 1334 | (setq org-todo-keywords 1335 | '((sequence "TODO(t)" "INITIATED(i!)" "WAITING(w!)" "CAL(a)" "SOMEDAY(s!)" "PROJ(j)" "|" "DONE(d!)" "CANCELLED(c!)"))) 1336 | 1337 | (setq org-refile-targets '(("/Users/blaine/gtd/tasks/JournalArticles.org" :maxlevel . 2) 1338 | ("/Users/blaine/gtd/tasks/Proposals.org" :maxlevel . 2) 1339 | ("/Users/blaine/gtd/tasks/Books.org" :maxlevel . 2) 1340 | ("/Users/blaine/gtd/tasks/Talks.org" :maxlevel . 2) 1341 | ("/Users/blaine/gtd/tasks/Posters.org" :maxlevel . 2) 1342 | ("/Users/blaine/gtd/tasks/ManuscriptReviews.org" :maxlevel . 2) 1343 | ("/Users/blaine/gtd/tasks/Private.org" :maxlevel . 2) 1344 | ("/Users/blaine/gtd/tasks/Service.org" :maxlevel . 2) 1345 | ("/Users/blaine/gtd/tasks/Teaching.org" :maxlevel . 2) 1346 | ("/Users/blaine/gtd/tasks/grasscatcer.org" :maxlevel . 2) 1347 | ("/Users/blaine/gtd/tasks/Workshops.org" :maxlevel . 2))) 1348 | (setq org-refile-use-outline-path 'file) 1349 | 1350 | ;; ***** customized agenda views 1351 | ;; 1352 | ;; These are my customized agenda views by project. 1353 | ;; The letter is the last parameter. 1354 | ;; For example, enter ~C-c a b~ and then enter 402 at the prompt to list all active tasks related to 402 tasks. 1355 | ;; 1356 | ;; I learned about this approach [[https://tlestang.github.io/blog/keeping-track-of-tasks-and-projects-using-emacs-and-org-mode.html][here]]. 1357 | ;; 1358 | ;; The CATEGORY keyword resides inside of a Properties drawer. 1359 | ;; The drawers are usually closed. 1360 | ;; I am having trouble opening my drawers in may org files. 1361 | ;; In addition, I do not want to have to add a drawer to each TODO. 1362 | ;; 1363 | ;; I am loving Tags now. 1364 | ;; I may switch to using Tags because they are visible in org files. 1365 | ;; I tried and they are not leading to the expect list of TODOs in org-agenda. 1366 | ;; I am stumped. 1367 | ;; 1368 | ;; In the meantime, enter ~C-c \~ inside JournalArticles.org to narrow the focus to the list of TODOs or enter ~C-c i b~ to get an indirect buffer. 1369 | ;; 1370 | 1371 | (setq org-agenda-custom-commands 1372 | '( 1373 | ("b" 1374 | "List of all active 402 tasks." 1375 | tags-todo 1376 | "402\"/TODO|INITIATED|WAITING") 1377 | ("c" 1378 | "List of all active 523 RNA-drug crystallization review paper tasks." 1379 | tags-todo 1380 | "CATEGORY=\"523\"/TODO|INITIATED|WAITING") 1381 | ("d" 1382 | "List of all active 485PyMOLscGUI tasks." 1383 | tags-todo 1384 | "CATEGORY=\"485\"/TODO|INITIATED|WAITING") 1385 | ("e" 1386 | "List of all active 2104 Emacs tasks" 1387 | tags-todo 1388 | "2104+CATEGORY=\"2104\"/NEXT|TODO|INITIATED|WAITING") 1389 | ("n" 1390 | "List of all active 651 ENAX2 tasks" 1391 | tags-todo 1392 | "651+CATEGORY=\"651\"/NEXT|TODO|INITIATED|WAITING") 1393 | ("q" 1394 | "List of all active 561 charge density review" 1395 | tags 1396 | "561+CATEGORY=\"211\"/NEXT|TODO|INITIATED|WAITING") 1397 | ("r" 1398 | "List of all active 211 rcl/dnph tasks" 1399 | tags-todo 1400 | "211+CATEGORY=\"211\"/NEXT|TODO|INITIATED|WAITING") 1401 | ("P" 1402 | "List of all projects" 1403 | tags 1404 | "LEVEL=2/PROJ"))) 1405 | 1406 | 1407 | ;; I usually know the project to which I want to assign a task. 1408 | ;; I loathe having to come back latter to refile my tasks. 1409 | ;; I want to do the filing at the time of capture. 1410 | ;; I found a solution [[https://stackoverflow.com/questions/9005843/interactively-enter-headline-under-which-to-place-an-entry-using-capture][here]]. 1411 | ;; 1412 | ;; A project has two or more tasks. 1413 | ;; I believe that the 10,000 projects is the upper limit for a 30 year academic career. 1414 | ;; There are about 10,000 workdays in a 30 year career if you work six days a week. 1415 | ;; Of course, most academics work seven a week and many work longer than 30 years, some even reach 60 years. 1416 | ;; 1417 | ;; I have my projects split into ten org files. 1418 | ;; Each org file has a limit of 1000 projects for ease of scrolling. 1419 | ;; 1420 | ;; It is best to let Emacs insert new task because it is easy to accidently delete sectons in an org file, especially when sections are folded. 1421 | ;; (I know that many love folded sections. 1422 | ;; There is a strong appeal to being able to collapse secitons of text. 1423 | ;; However, folded section are not for me; I have experienced too many catastrophes. 1424 | ;; I open all of my org files with all sections fully open. 1425 | ;; I can use swiper to navigate if I do not want to scroll.) 1426 | ;; Enter ~C-c c~ to start the capture menu. 1427 | ;; The settings below show a single letter option for selecting the appropriate org-file. 1428 | ;; After entering the single-letter code, you are prompted for the headline name. 1429 | ;; You do not have to include the TODO keyword. 1430 | ;; However, I changed "Headline" to "Tag" because I have the project ID was one of the tags on the same line as the project headline. 1431 | ;; I am now prompted for the tag. 1432 | ;; After entering the tag, I fill out the task entry. 1433 | ;; I then enter ~C-c C-c~ to save the capture. 1434 | ;; 1435 | ;;This protocol can be executed from inside the target org file or from a different buffer. 1436 | ;; 1437 | ;;I learned about the following function, which I modified by changing "Headline " to "Tag", from 1438 | ;;[[https://stackoverflow.com/questions/9005843/interactively-enter-headline-under-which-to-place-an-entry-using-capture][Lionel Henry]] with the modification by Phil on July 1, 2018. 1439 | ;; 1440 | (defun org-ask-location () 1441 | (let* ((org-refile-targets '((nil :maxlevel . 9))) 1442 | (hd (condition-case nil 1443 | (car (org-refile-get-location "Tag" nil t)) 1444 | (error (car org-refile-history))))) 1445 | (goto-char (point-min)) 1446 | (outline-next-heading) 1447 | (if (re-search-forward 1448 | (format org-complex-heading-regexp-format (regexp-quote hd)) 1449 | nil t) 1450 | (goto-char (point-at-bol)) 1451 | (goto-char (point-max)) 1452 | (or (bolp) (insert "\n")) 1453 | (insert "* " hd "\n"))) 1454 | (end-of-line)) 1455 | 1456 | 1457 | (setq org-capture-templates 1458 | '( 1459 | ("j" "JournalArticles" entry 1460 | (file+function "/Users/blaine/gtd/tasks/JournalArticles.org" org-ask-location) 1461 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1462 | :empty-lines 1) 1463 | ("g" "GrantProposals" entry 1464 | (file+function "/Users/blaine/gtd/tasks/Proposals.org" org-ask-location) 1465 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1466 | :empty-lines 1) 1467 | ("b" "Books" entry 1468 | (file+function "/Users/blaine/gtd/tasks/Books.org" org-ask-location) 1469 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1470 | :empty-lines 1) 1471 | ("t" "Talks" entry 1472 | (file+function "/Users/blaine/gtd/tasks/Talks.org" org-ask-location) 1473 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1474 | :empty-lines 1) 1475 | ("p" "Posters" entry 1476 | (file+function "/Users/blaine/gtd/tasks/Posters.org" org-ask-location) 1477 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1478 | :empty-lines 1) 1479 | ("r" "ManuscriptReviews" entry 1480 | (file+function "/Users/blaine/gtd/tasks/ManuscriptReviews.org" org-ask-location) 1481 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1482 | :empty-lines 1) 1483 | ("v" "Private" entry 1484 | (file+function "/Users/blaine/gtd/tasks/Private.org" org-ask-location) 1485 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1486 | :empty-lines 1) 1487 | ("S" "Service" entry 1488 | (file+function "/Users/blaine/gtd/tasks/Service.org" org-ask-location) 1489 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1490 | :empty-lines 1) 1491 | ("T" "Teaching" entry 1492 | (file+function "/Users/blaine/gtd/tasks/Teaching.org" org-ask-location) 1493 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1494 | :empty-lines 1) 1495 | ("w" "Workshop" entry 1496 | (file+function "/Users/blaine/gtd/tasks/Workshops.org" org-ask-location) 1497 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1498 | :empty-lines 1) 1499 | ("s" "Slipbox" entry (file "/User/org-roam/inbox.org") 1500 | "* %?\n") 1501 | )) 1502 | 1503 | 1504 | (defun jethro/org-capture-slipbox () 1505 | (interactive) 1506 | (org-capture nil "s")) 1507 | 1508 | 1509 | ;; <<<<<<< END of org-agenda >>>>>>>>>>>>>> 1510 | 1511 | 1512 | ;; org-drill for spaced repetition learning in org-mode 1513 | ;; You have to install org-drill from MELPA.;; This is a YouTube video about how to use org-drill[[https://www.youtube.com/watch?v=uraPXeLfWcM][to learn Chinese]]. 1514 | ;;You can use org tables to generate [[https://github.com/chrisbarrett/org-drill-table][flashcards]]. 1515 | (use-package org-drill 1516 | :ensure t 1517 | :config (progn 1518 | (add-to-list 'org-modules 'org-drill) 1519 | (setq org-drill-add-random-noise-to-intervals-p t) 1520 | (setq org-drill-hint-separator "||") 1521 | (setq org-drill-left-cloze-delimiter "<[") 1522 | (setq org-drill-right-cloze-delimiter "]>") 1523 | (setq org-drill-learn-fraction 0.25) 1524 | ) 1525 | ) 1526 | 1527 | 1528 | (use-package org-pomodoro 1529 | :ensure t 1530 | :commands (org-pomodoro) 1531 | :config 1532 | (setq alert-user-configuration (quote ((((:category . "org-pomodoro")) libnotify nil))))) 1533 | 1534 | ;; (use-package sound-wav) 1535 | ;; (setq org-pomodoro-ticking-sound-p nil) 1536 | ;; ; (setq org-pomodoro-ticking-sound-states '(:pomodoro :short-break :long-break)) 1537 | ;; (setq org-pomodoro-ticking-sound-states '(:pomodoro)) 1538 | ;; (setq org-pomodoro-ticking-frequency 1) 1539 | ;; (setq org-pomodoro-audio-player "mplayer") 1540 | ;; (setq org-pomodoro-finished-sound-args "-volume 0.9") 1541 | ;; (setq org-pomodoro-long-break-sound-args "-volume 0.9") 1542 | ;; (setq org-pomodoro-short-break-sound-args "-volume 0.9") 1543 | ;; (setq org-pomodoro-ticking-sound-args "-volume 0.3") 1544 | 1545 | (global-set-key (kbd "C-c o") 'org-pomodoro) 1546 | 1547 | 1548 | 1549 | ;; <<<<<<< BEGIN org-ref >>>>>>>>>>>>>> 1550 | (use-package org-ref 1551 | :ensure t) 1552 | (require 'org-ref-ivy) 1553 | (use-package bibtex 1554 | :ensure t) 1555 | 1556 | (setq bibtex-completion-bibliography '("/Users/blaine/Documents/global.bib") 1557 | bibtex-completion-library-path '("/Users/blaine/0papersLabeled/") 1558 | bibtex-completion-notes-path "/Users/blaine/Documents/notes/" 1559 | bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n" 1560 | bibtex-completion-additional-search-fields '(keywords) 1561 | bibtex-completion-display-formats 1562 | '((article . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}") 1563 | (inbook . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}") 1564 | (incollection . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 1565 | (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 1566 | (t . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}")) 1567 | bibtex-completion-pdf-open-function 1568 | (lambda (fpath) 1569 | (call-process "open" nil 0 nil fpath))) 1570 | 1571 | (setq bibtex-autokey-year-length 4 1572 | bibtex-autokey-name-year-separator "-" 1573 | bibtex-autokey-year-title-separator "-" 1574 | bibtex-autokey-titleword-separator "-" 1575 | bibtex-autokey-titlewords 2 1576 | bibtex-autokey-titlewords-stretch 1 1577 | bibtex-autokey-titleword-length 5) 1578 | 1579 | ;; H is the hyper key. I have bound H to Fn. For the MacAlly keyboard, it is bound to right-command. 1580 | (define-key bibtex-mode-map (kbd "H-b") 'org-ref-bibtex-hydra/body) 1581 | (define-key org-mode-map (kbd "H-c") org-ref-insert-cite-function) 1582 | (define-key org-mode-map (kbd "H-r") org-ref-insert-ref-function) 1583 | (define-key org-mode-map (kbd "H-l") org-ref-insert-label-function) 1584 | (define-key org-mode-map (kbd "H-d") 'doi-add-bibtex-entry) 1585 | 1586 | 1587 | ;; <<<<<<< END org-ref >>>>>>>>>>>>>> 1588 | 1589 | 1590 | 1591 | 1592 | ;; <<<<<<< BEGIN org-roam >>>>>>>>>>>>>> 1593 | 1594 | ;; ** Basic org-roam config 1595 | (use-package org-roam 1596 | :ensure t 1597 | :custom 1598 | (org-roam-directory (file-truename "/Users/blaine/org-roam/")) 1599 | :bind (("C-c n l" . org-roam-buffer-toggle) 1600 | ("C-c n f" . org-roam-node-find) 1601 | ("C-c n g" . org-roam-graph) 1602 | ("C-c n i" . org-roam-node-insert) 1603 | ("C-c n c" . org-roam-capture) 1604 | ;; Dailies 1605 | ("C-c n j" . org-roam-dailies-capture-today)) 1606 | :config 1607 | ;; If you're using a vertical completion framework, you might want a more informative completion interface 1608 | (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) 1609 | (org-roam-db-autosync-mode) 1610 | (org-roam-ui-mode) 1611 | ;; If using org-roam-protocol 1612 | (require 'org-roam-protocol)) 1613 | 1614 | 1615 | ;; ** Basic org-roam config 1616 | ;; Following https://jethrokuan.github.io/org-roam-guide/ 1617 | 1618 | (setq org-roam-capture-templates 1619 | '(("m" "main" plain 1620 | "%?" 1621 | :if-new (file+head "main/${slug}.org" "#+title: ${title}\n\n\n\n* References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n") 1622 | :immediate-finish t 1623 | :unnarrowed t) 1624 | ("r" "reference" plain "%?" 1625 | :if-new 1626 | (file+head "reference/${title}.org" "#+title: ${title}\n\n\n\n\n* References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n") 1627 | :immediate-finish t 1628 | :unnarrowed t) 1629 | ("a" "article" plain "%?" 1630 | :if-new 1631 | (file+head "articles/${title}.org" "#+title: ${title}\n#+filetags: :article:\n\n\n\n\n* References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n") 1632 | :immediate-finish t 1633 | :unnarrowed t))) 1634 | 1635 | 1636 | (setq org-roam-node-display-template 1637 | (concat "${type:15} ${title:*} " (propertize "${tags:10}" 'face 'org-tag))) 1638 | 1639 | 1640 | (defun jethro/org-roam-node-from-cite (keys-entries) 1641 | (interactive (list (citar-select-ref :multiple nil :rebuild-cache t))) 1642 | (let ((title (citar--format-entry-no-widths (cdr keys-entries) 1643 | "${author editor} :: ${title}"))) 1644 | (org-roam-capture- :templates 1645 | '(("r" "reference" plain "%?" :if-new 1646 | (file+head "reference/${citekey}.org" 1647 | ":PROPERTIES: 1648 | :ROAM_REFS: [cite:@${citekey}] 1649 | :END: 1650 | #+title: ${title}\n") 1651 | :immediate-finish t 1652 | :unnarrowed t)) 1653 | :info (list :citekey (car keys-entries)) 1654 | :node (org-roam-node-create :title title) 1655 | :props '(:finalize find-file)))) 1656 | 1657 | 1658 | (defun jethro/tag-new-node-as-draft () 1659 | (org-roam-tag-add '("draft"))) 1660 | (add-hook 'org-roam-capture-new-node-hook #'jethro/tag-new-node-as-draft) 1661 | 1662 | 1663 | 1664 | ;; settings to enable rendering of LaTeX equations with org-latex-preview with C-c C-x C-l 1665 | ;; I tried to get org-latex-preview to work without success on 12-10-2022 1666 | ;; I had to install texlive-xelatex via macports. 1667 | ;; 1668 | 1669 | 1670 | (setq org-preview-latex-default-process 'dvisvgm) 1671 | 1672 | (setq org-latex-to-pdf-process 1673 | '("xelatex -interaction nonstopmode %f" 1674 | "xelatex -interaction nonstopmode %f")) ;; for multiple passes 1675 | 1676 | ;; Increase size of LaTeX fragment previews. Note that the previews do not scale up with C-x + 1677 | (plist-put org-format-latex-options :scale 2) 1678 | 1679 | ;; *** Create the property “type” on my nodes. 1680 | 1681 | ;; (cl-defmethod org-roam-node-type ((node org-roam-node)) 1682 | ;; "Return the TYPE of NODE." 1683 | ;; (condition-case nil 1684 | ;; (file-name-nondirectory 1685 | ;; (directory-file-name 1686 | ;; (file-name-directory 1687 | ;; (file-relative-name (org-roam-node-file node) org-roam-directory)))) 1688 | ;; (error ""))) 1689 | ;; 1690 | 1691 | ;;(setq org-roam-node-display-template 1692 | ;; (concat "${type:15} ${title:*} " (propertize "${tags:10}" 'face 'org-tag))) 1693 | ;; 1694 | 1695 | 1696 | 1697 | ;; *** org-roam-bibtex config 1698 | 1699 | (use-package org-roam-bibtex 1700 | :hook (org-roam-mode . org-roam-bibtex-mode)) 1701 | 1702 | (setq orb-preformat-keywords 1703 | '("citekey" "title" "url" "author-or-editor" "keywords" "file") 1704 | orb-process-file-keyword t 1705 | orb-file-field-extensions '("pdf")) 1706 | 1707 | (setq orb-templates 1708 | '(("r" "ref" plain(function org-roam-capture--get-point) 1709 | "" 1710 | :file-name "${citekey}" 1711 | :head "#+TITLE: ${citekey}: ${title}\n#+ROAM_KEY: ${ref} 1712 | - tags :: 1713 | - keywords :: ${keywords} 1714 | 1715 | *Notes 1716 | :PROPERTIES: 1717 | :Custom_ID: ${citekey} 1718 | :URL: ${url} 1719 | :AUTHOR: ${author-or-editor} 1720 | :NOTER_DOCUMENT: ${file} 1721 | :NOTER_PAGE: 1722 | :END:"))) 1723 | 1724 | 1725 | (use-package citar-org-roam 1726 | :after citar org-roam 1727 | :no-require 1728 | :config (citar-org-roam-mode)) 1729 | 1730 | 1731 | (use-package citar 1732 | :bind (("C-c b" . citar-insert-citation) 1733 | :map minibuffer-local-map 1734 | ("M-b" . citar-insert-preset)) 1735 | :custom 1736 | (citar-bibliography '("/Users/blaine/Documents/global.bib"))) 1737 | 1738 | (setenv "PATH" (concat ":/opt/local/bin/" (getenv "PATH"))) 1739 | (add-to-list 'exec-path "/opt/local/bin/") 1740 | 1741 | ;; org-preview-latex-process-alist 1742 | 1743 | ;; org-preview-latex-default-process 1744 | 1745 | ;; <<<<<<< END org-roam >>>>>>>>>>>>>> 1746 | 1747 | 1748 | ;; source: https://www.reddit.com/r/emacs/comments/zjv1gj/org_files_to_docx/ 1749 | 1750 | (defun hm/convert-org-to-docx-with-pandoc () 1751 | "Use Pandoc to convert .org to .docx. 1752 | Comments: 1753 | The `-N' flag numbers the headers lines. 1754 | Use the `--from org' flag to have this function work on files 1755 | that are in Org syntax but do not have a .org extension" 1756 | (interactive) 1757 | (message "exporting .org to .docx") 1758 | (shell-command 1759 | (concat "pandoc -N --from org " (buffer-file-name) 1760 | " -o " 1761 | (file-name-sans-extension (buffer-file-name)) 1762 | (format-time-string "-%Y-%m-%d-%H%M%S") ".docx"))) 1763 | 1764 | (defalias 'o2d 'hm/convert-org-to-docx) 1765 | 1766 | 1767 | 1768 | 1769 | 1770 | 1771 | ;; ** P 1772 | 1773 | ;; Paredit makes paranthesis handling a breeze in Lisp-languages. 1774 | ;; Only setting I really need is to make it possible to select something 1775 | ;; and delete the selection (including the paranthesis). 1776 | 1777 | ;; (use-package paredit 1778 | ;; :config 1779 | ;; ;; making paredit work with delete-selection-mode 1780 | ;; ;; found on the excellent place called what the emacs d. 1781 | ;; (put 'paredit-forward-delete 'delete-selection 'supersede) 1782 | ;; (put 'paredit-backward-delete 'delete-selection 'supersede) 1783 | ;; (put 'paredit-open-round 'delete-selection t) 1784 | ;; (put 'paredit-open-square 'delete-selection t) 1785 | ;; (put 'paredit-doublequote 'delete-selection t) 1786 | ;; (put 'paredit-newline 'delete-selection t) 1787 | ;; :hook 1788 | ;; ((emacs-lisp-mode . paredit-mode) 1789 | ;; (scheme-mode . paredit-mode))) 1790 | 1791 | 1792 | ;; *** Move to cursor to previously visited window 1793 | ;; From the book Writing GNU Emacs Extensions by Bill Glickstein. 1794 | (defun other-window-backward (&optional n) 1795 | "Select Nth previous window." 1796 | (interactive "P") 1797 | (other-window (- (prefix-numeric-value n)))) 1798 | 1799 | (global-set-key "\C-xp" 'other-window-backward) 1800 | 1801 | 1802 | ;; ** pdb-tools 1803 | 1804 | ;;Marcin Magnus's updated fork of pdb-tools by Charlie Bond and David Love. 1805 | ;;[[https://github.com/mmagnus/emacs-pdb-mode][Gitub repo]]] 1806 | 1807 | 1808 | ;; pdb.el 1809 | (load-file "~/latex-emacs29/manual-packages/emacs-pdb-mode/pdb-mode.el") 1810 | (setq pdb-rasmol-name "/Applications/PyMOL.app/Contents/bin/pymol") 1811 | (setq auto-mode-alist 1812 | (cons (cons "pdb$" 'pdb-mode) 1813 | auto-mode-alist ) ) 1814 | (autoload 'pdb-mode "PDB") 1815 | 1816 | 1817 | 1818 | 1819 | ;;### pdf-tools 1820 | 1821 | ;; This is an alternative to the built-in DocView package. 1822 | ;; I allows smooth scrolling and it superior in general. 1823 | ;; I could load several PDFs, including 500 pages books. 1824 | ;; 1825 | ;; 1826 | ;; The pdf-tools package runs on top of pdf-view package. 1827 | ;; This making capturing text from PDFs much easier. 1828 | ;; 1829 | ;; I followed a [[http://pragmaticemacs.com/emacs/view-and-annotate-pdfs-in-emacs-with-pdf-tools][blog post]]. 1830 | ;; You enter highlights by selecting with the mouse and entering C-c C-a h. 1831 | ;; An annotation menu opens in the minibuffer. 1832 | ;; Enter ~C-c C-c~ to save the annotation. 1833 | ;; Enter ~C-c C-a t~ to enter text notes. 1834 | ;; Enter the note and enter ~C-c C-c~ to save. 1835 | ;; Right-click the mouse to get a menu of more options. 1836 | 1837 | 1838 | (use-package pdf-tools 1839 | ;;:pin manual ;; manually update 1840 | :config 1841 | ;; initialise 1842 | (pdf-tools-install) 1843 | 1844 | ;; This means that pdfs are fitted to width by default when you open them 1845 | (setq-default pdf-view-display-size 'fit-width) 1846 | ;; open pdfs scaled to fit page 1847 | ;; (setq-default pdf-view-display-size 'fit-page) 1848 | ;; automatically annotate highlights 1849 | (setq pdf-annot-activate-created-annotations t) 1850 | ;; use normal isearch 1851 | (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)) 1852 | ;; Setting for sharper images with Macs with Retina displays 1853 | (setq pdf-view-use-scaling t) 1854 | 1855 | 1856 | 1857 | ;; **** Useful keybindings for viewing PDFs 1858 | ;; |------------------------------------------+-----------------| 1859 | ;; | Display | | 1860 | ;; |------------------------------------------+-----------------| 1861 | ;; | Zoom in / Zoom out | ~+~ / ~-~ | 1862 | ;; | Fit height / Fit width / Fit page | ~H~ / ~W~ / ~P~ | 1863 | ;; | Trim margins (set slice to bounding box) | ~s b~ | 1864 | ;; | Reset margins | ~s r~ | 1865 | ;; | Reset z oom | ~0~ | 1866 | ;; |------------------------------------------+-----------------| 1867 | ;; 1868 | ;; **** Useful keybindings for navigating PDFs 1869 | ;; 1870 | ;; |-----------------------------------------------+-----------------------| 1871 | ;; | Navigation | | 1872 | ;; |-----------------------------------------------+-----------------------| 1873 | ;; | Scroll Up / Down by Page-full | ~space~ / ~backspace~ | 1874 | ;; | Scroll Up / Down by Line | ~C-n~ / ~C-p~ | 1875 | ;; | Scroll Right / Left | ~C-f~ / ~C-b~ | 1876 | ;; | First Page / Last Page | ~<~ / ~>~ | 1877 | ;; | Next Page / Previous Page | ~n~ / ~p~ | 1878 | ;; | First Page / Last Page | ~M-<~ / ~M->~ | 1879 | ;; | Incremental Search Forward / Backward | ~C-s~ / ~C-r~ | 1880 | ;; | Occur (list all lines containing a phrase) | ~M-s o~ | 1881 | ;; | Jump to Occur Line | ~RETURN~ | 1882 | ;; | Pick a Link and Jump | ~F~ | 1883 | ;; | Incremental Search in Links | ~f~ | 1884 | ;; | History Back / Forwards | ~l~ / ~r~ | 1885 | ;; | Display Outline | ~o~ | 1886 | ;; | Jump to Section from Outline | ~RETURN~ | 1887 | ;; | Jump to Page | ~M-g g~ | 1888 | ;; | Store position / Jump to position in register | ~m~ / ~'~ | 1889 | ;; |-----------------------------------------------+-----------------------| 1890 | ;; 1891 | 1892 | 1893 | ;; *** projectile 1894 | (use-package projectile 1895 | :ensure t) 1896 | (projectile-mode +1) 1897 | (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map) 1898 | (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) 1899 | 1900 | 1901 | ;; *** Python 1902 | 1903 | ;; I sometimes write Python code for various things, sometimes as a calculator 1904 | ;; :P (SymPy, NumPy and MatplotLib <3 ). 1905 | ;; 1906 | ;; I choose to start lsp manually due to sometimes not needing a language server 1907 | ;; for minor edits (which is what I mostly do with Python). 1908 | 1909 | (use-package lsp-pyright 1910 | :after lsp-mode 1911 | :init 1912 | (require 'lsp-pyright)) 1913 | 1914 | 1915 | 1916 | ;;** S 1917 | 1918 | 1919 | ;; *** Straight 1920 | ;; Install straight.el 1921 | (defvar bootstrap-version) 1922 | (let ((bootstrap-file 1923 | (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) 1924 | (bootstrap-version 5)) 1925 | (unless (file-exists-p bootstrap-file) 1926 | (with-current-buffer 1927 | (url-retrieve-synchronously 1928 | "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" 1929 | 'silent 'inhibit-cookies) 1930 | (goto-char (point-max)) 1931 | (eval-print-last-sexp))) 1932 | (load bootstrap-file nil 'nomessage)) 1933 | 1934 | 1935 | ;;### pdf-drop-mode 1936 | (straight-use-package 1937 | '(pdf-drop-mode :type git :host github :repo "rougier/pdf-drop-mode")) 1938 | 1939 | 1940 | (require 'pdf-drop-mode) 1941 | 1942 | (defun my/pdf-process (file doi) 1943 | (message "%s : %s" file doi)) 1944 | 1945 | (setq pdf-drop-search-hook #'my/pdf-process) 1946 | (pdf-drop-mode) 1947 | 1948 | 1949 | ;;### Swiper related confg from https://github.com/zamansky/using-emacs/blob/lesson-6-swiper/init.el 1950 | (use-package try 1951 | :ensure t) 1952 | 1953 | 1954 | ;; Org-mode stuff 1955 | (use-package org-bullets 1956 | :ensure t 1957 | :config 1958 | (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))) 1959 | 1960 | (setq ido-enable-flex-matching t) 1961 | (setq ido-everywhere t) 1962 | (ido-mode 1) 1963 | 1964 | (defalias 'list-buffers 'ibuffer) 1965 | ;; (defalias 'list-buffers 'ibuffer-other-window) 1966 | 1967 | ; If you like a tabbar 1968 | ;(use-package tabbar 1969 | ; :ensure t 1970 | ; :config 1971 | ; (tabbar-mode 1)) 1972 | 1973 | 1974 | (use-package ace-window 1975 | :ensure t 1976 | :init 1977 | (progn 1978 | (global-set-key [remap other-window] 'ace-window) 1979 | (custom-set-faces 1980 | '(aw-leading-char-face 1981 | ((t (:inherit ace-jump-face-foreground :height 3.0))))) 1982 | )) 1983 | 1984 | 1985 | ;; it looks like counsel is a requirement for swiper 1986 | (use-package counsel 1987 | :ensure t 1988 | ) 1989 | 1990 | (use-package swiper 1991 | :ensure try 1992 | :config 1993 | (progn 1994 | (ivy-mode 1) 1995 | (setq ivy-use-virtual-buffers t) 1996 | (global-set-key "\C-s" 'swiper) 1997 | (global-set-key (kbd "C-c C-r") 'ivy-resume) 1998 | (global-set-key (kbd "") 'ivy-resume) 1999 | (global-set-key (kbd "M-x") 'counsel-M-x) 2000 | (global-set-key (kbd "C-x C-f") 'counsel-find-file) 2001 | (global-set-key (kbd " f") 'counsel-describe-function) 2002 | (global-set-key (kbd " v") 'counsel-describe-variable) 2003 | (global-set-key (kbd " l") 'counsel-load-library) 2004 | (global-set-key (kbd " i") 'counsel-info-lookup-symbol) 2005 | (global-set-key (kbd " u") 'counsel-unicode-char) 2006 | (global-set-key (kbd "C-c g") 'counsel-git) 2007 | (global-set-key (kbd "C-c j") 'counsel-git-grep) 2008 | (global-set-key (kbd "C-c k") 'counsel-ag) 2009 | (global-set-key (kbd "C-x l") 'counsel-locate) 2010 | (global-set-key (kbd "C-S-o") 'counsel-rhythmbox) 2011 | (define-key read-expression-map (kbd "C-r") 'counsel-expression-history) 2012 | )) 2013 | 2014 | 2015 | ;; ;; ** T 2016 | ;; ;; *** tabspaces 2017 | ;; ;; Source: 2018 | ;; 2019 | ;; (use-package tabspaces 2020 | ;; ;; use this next line only if you also use straight, otherwise ignore it. 2021 | ;; :straight (:type git :host github :repo "mclear-tools/tabspaces") 2022 | ;; :hook (after-init . tabspaces-mode) ;; use this only if you want the minor-mode loaded at startup. 2023 | ;; :commands (tabspaces-switch-or-create-workspace 2024 | ;; tabspaces-open-or-create-project-and-workspace) 2025 | ;; :custom 2026 | ;; (tabspaces-use-filtered-buffers-as-default t) 2027 | ;; (tabspaces-default-tab "Default") 2028 | ;; (tabspaces-remove-to-default t) 2029 | ;; (tabspaces-include-buffers '("*scratch*")) 2030 | ;; ;; sessions 2031 | ;; (tabspaces-session t) 2032 | ;; (tabspaces-session-auto-restore t)) 2033 | ;; 2034 | ;; (defvar tabspaces-command-map 2035 | ;; (let ((map (make-sparse-keymap))) 2036 | ;; (define-key map (kbd "C") 'tabspaces-clear-buffers) 2037 | ;; (define-key map (kbd "b") 'tabspaces-switch-to-buffer) 2038 | ;; (define-key map (kbd "d") 'tabspaces-close-workspace) 2039 | ;; (define-key map (kbd "k") 'tabspaces-kill-buffers-close-workspace) 2040 | ;; (define-key map (kbd "o") 'tabspaces-open-or-create-project-and-workspace) 2041 | ;; (define-key map (kbd "r") 'tabspaces-remove-current-buffer) 2042 | ;; (define-key map (kbd "R") 'tabspaces-remove-selected-buffer) 2043 | ;; (define-key map (kbd "s") 'tabspaces-switch-or-create-workspace) 2044 | ;; (define-key map (kbd "t") 'tabspaces-switch-buffer-and-tab) 2045 | ;; map) 2046 | ;; "Keymap for tabspace/workspace commands after `tabspaces-keymap-prefix'.") 2047 | ;; 2048 | ;; ;; If you use ivy you can use this function to limit your buffer search to only those in the tabspace. 2049 | ;; (defun tabspaces-ivy-switch-buffer (buffer) 2050 | ;; "Display the local buffer BUFFER in the selected window. 2051 | ;; This is the frame/tab-local equivilant to `switch-to-buffer'." 2052 | ;; (interactive 2053 | ;; (list 2054 | ;; (let ((blst (mapcar #'buffer-name (tabspaces-buffer-list)))) 2055 | ;; (read-buffer 2056 | ;; "Switch to local buffer: " blst nil 2057 | ;; (lambda (b) (member (if (stringp b) b (car b)) blst)))))) 2058 | ;; (ivy-switch-buffer buffer)) 2059 | ;; 2060 | ;; 2061 | ;; ;; By default the *scratch* buffer is included in all workspaces. 2062 | ;; ;; You can modify which buffers are included by default by changing the value of tabspaces-include-buffers. 2063 | ;; ;; If you want emacs to startup with a set of initial buffers in a workspace, do something like the following: 2064 | ;; 2065 | ;; 2066 | ;; 2067 | ;; (defun my--tabspace-setup () 2068 | ;; "Set up tabspace at startup." 2069 | ;; ;; Add *Messages* and *splash* to Tab \`Home\' 2070 | ;; (tabspaces-mode 1) 2071 | ;; (progn 2072 | ;; (tab-bar-rename-tab "Home") 2073 | ;; (when (get-buffer "*Messages*") 2074 | ;; (set-frame-parameter nil 2075 | ;; 'buffer-list 2076 | ;; (cons (get-buffer "*Messages*") 2077 | ;; (frame-parameter nil 'buffer-list)))) 2078 | ;; (when (get-buffer "*splash*") 2079 | ;; (set-frame-parameter nil 2080 | ;; 'buffer-list 2081 | ;; (cons (get-buffer "*splash*") 2082 | ;; (frame-parameter nil 'buffer-list)))))) 2083 | ;; 2084 | ;; (add-hook 'after-init-hook #'my--tabspace-setup) 2085 | ;; 2086 | ;; ;; *** TeXcount setup for TeXcount version 2.3 and later 2087 | ;; ;; See https://app.uio.no/ifi/texcount/howto.html to use from the command line. 2088 | ;; (defun texcount () 2089 | ;; (interactive) 2090 | ;; (let* 2091 | ;; ( (this-file (buffer-file-name)) 2092 | ;; (enc-str (symbol-name buffer-file-coding-system)) 2093 | ;; (enc-opt 2094 | ;; (cond 2095 | ;; ((string-match "utf-8" enc-str) "-utf8") 2096 | ;; ((string-match "latin" enc-str) "-latin1") 2097 | ;; ("-encoding=guess") 2098 | ;; ) ) 2099 | ;; (word-count 2100 | ;; (with-output-to-string 2101 | ;; (with-current-buffer standard-output 2102 | ;; (call-process "/opt/local/bin/texcount" nil t nil "-0" enc-opt this-file) 2103 | ;; ) ) ) ) 2104 | ;; (message word-count) 2105 | ;; ) ) 2106 | ;; (add-hook 'LaTeX-mode-hook (lambda () (define-key LaTeX-mode-map "\C-cw" 'texcount))) 2107 | ;; (add-hook 'latex-mode-hook (lambda () (define-key latex-mode-map "\C-cw" 'texcount))) 2108 | 2109 | 2110 | 2111 | ;; *** activate word count mode 2112 | ;; This mode will count the LaTeX markup, but it does give the count of incrementally added words. 2113 | (use-package wc-mode) 2114 | (add-hook 'text-mode-hook 'wc-mode) 2115 | ;; Suggested setting 2116 | (global-set-key "\C-cw" 'wc-mode) 2117 | 2118 | ;; *** Do NOT MESS with the code below 2119 | (custom-set-variables 2120 | ;; custom-set-variables was added by Custom. 2121 | ;; If you edit it by hand, you could mess it up, so be careful. 2122 | ;; Your init file should contain only one such instance. 2123 | ;; If there is more than one, they won't work right. 2124 | '(ac-menu-height 15) 2125 | '(ivy-height 20) 2126 | '(org-agenda-files 2127 | '("~/430PSADwaveOpt/430gh/main.org" "/Users/blaine/gtd/tasks/JournalArticles.org" "/Users/blaine/gtd/tasks/Proposals.org" "/Users/blaine/gtd/tasks/Books.org" "/Users/blaine/gtd/tasks/Talks.org" "/Users/blaine/gtd/tasks/Posters.org" "/Users/blaine/gtd/tasks/ManuscriptReviews.org" "/Users/blaine/gtd/tasks/Private.org" "/Users/blaine/gtd/tasks/Service.org" "/Users/blaine/gtd/tasks/Teaching.org" "/Users/blaine/gtd/tasks/Workshops.org")) 2128 | '(package-selected-packages 2129 | '(counsel ace-window org-bullets which-key try languagetool org-ref org-pomodoro pdf-tools dirvish dired-icon 0xc org-pdftools multiple-cursors 0blayout dired-subtree org-roam-timestamps org-roam-bibtex org-roam-ui org-roam org-preview-html impatient-mode ef-themes yasnippet wc-mode use-package rainbow-delimiters powerline maxframe material-theme exec-path-from-shell electric-spacing better-defaults auto-complete auctex atomic-chrome)) 2130 | '(warning-suppress-log-types '(((tar link))))) 2131 | (custom-set-faces 2132 | ;; custom-set-faces was added by Custom. 2133 | ;; If you edit it by hand, you could mess it up, so be careful. 2134 | ;; Your init file should contain only one such instance. 2135 | ;; If there is more than one, they won't work right. 2136 | '(aw-leading-char-face ((t (:inherit ace-jump-face-foreground :height 3.0))))) 2137 | 2138 | 2139 | ;; *** Tramp 2140 | ;; Set default connection mode to SSH 2141 | (setq tramp-default-method "ssh") 2142 | 2143 | 2144 | ;; *** tree-sitter 2145 | 2146 | ;; (require 'tree-sitter) 2147 | ;; (require 'tree-sitter-langs) 2148 | ;; (require 'evil-textobj-tree-sitter) 2149 | ;; (global-tree-sitter-mode) 2150 | ;; 2151 | 2152 | 2153 | ;; ;; ** U 2154 | ;; ;; *** undo-tree 2155 | ;; (use-package undo-tree 2156 | ;; :init 2157 | ;; (global-undo-tree-mode) 2158 | ;; :custom 2159 | ;; (undo-tree-history-directory-alist '(("." . "~/latex-emacs/undo"))) 2160 | ;; ) 2161 | 2162 | 2163 | 2164 | 2165 | 2166 | 2167 | ;; ** W 2168 | ;; *** Which help 2169 | 2170 | (use-package which-key 2171 | :ensure t 2172 | :custom 2173 | (which-key-idle-delay 2) 2174 | :config 2175 | (which-key-mode)) 2176 | 2177 | ;; *** writeroom 2178 | ;; writeroom-mode for distraction-free writing. 2179 | 2180 | (with-eval-after-load 'writeroom-mode 2181 | (define-key writeroom-mode-map (kbd "C-M-<") #'writeroom-decrease-width) 2182 | (define-key writeroom-mode-map (kbd "C-M->") #'writeroom-increase-width) 2183 | (define-key writeroom-mode-map (kbd "C-M-=") #'writeroom-adjust-width)) 2184 | 2185 | 2186 | 2187 | 2188 | ;; ** Y 2189 | ;; *** yasnippet related 2190 | (use-package yasnippet 2191 | :ensure t 2192 | :config 2193 | (yas-global-mode 1) 2194 | :bind 2195 | ("C-c y i" . yas-insert-snippet) 2196 | ("C-c y n" . yas-new-snippet) 2197 | ) 2198 | (global-set-key "\C-o" 'yas-expand) 2199 | 2200 | (use-package popup 2201 | :ensure t) 2202 | ;; (require 'yasnippet) 2203 | ;; ;; add some shotcuts in popup menu mode 2204 | ;; (define-key popup-menu-keymap (kbd "M-n") 'popup-next) 2205 | ;; (define-key popup-menu-keymap (kbd "TAB") 'popup-next) 2206 | ;; (define-key popup-menu-keymap (kbd "") 'popup-next) 2207 | ;; (define-key popup-menu-keymap (kbd "") 'popup-previous) 2208 | ;; (define-key popup-menu-keymap (kbd "M-p") 'popup-previous) 2209 | ;; 2210 | ;; (defun yas/popup-isearch-prompt (prompt choices &optional display-fn) 2211 | ;; (when (featurep 'popup) 2212 | ;; (popup-menu* 2213 | ;; (mapcar 2214 | ;; (lambda (choice) 2215 | ;; (popup-make-item 2216 | ;; (or (and display-fn (funcall display-fn choice)) 2217 | ;; choice) 2218 | ;; :value choice)) 2219 | ;; choices) 2220 | ;; :prompt prompt 2221 | ;; ;; start isearch mode immediately 2222 | ;; :isearch t 2223 | ;; ))) 2224 | ;; (setq yas/prompt-functions '(yas/popup-isearch-prompt yas/no-prompt)) 2225 | ;; 2226 | ;; (defun complete-if-yas-field (&rest _) 2227 | ;; (let ((field (yas-current-field))) 2228 | ;; (when (and field 2229 | ;; (not (yas--field-modified-p field))) 2230 | ;; (company-manual-begin)))) 2231 | ;; 2232 | ;; (advice-add 'company-complete-selection :after 'complete-if-yas-field) 2233 | ;; (advice-add 'yas-next-field :after 'complete-if-yas-field) 2234 | 2235 | 2236 | (custom-set-variables 2237 | ;; custom-set-variables was added by Custom. 2238 | ;; If you edit it by hand, you could mess it up, so be careful. 2239 | ;; Your init file should contain only one such instance. 2240 | ;; If there is more than one, they won't work right. 2241 | '(package-selected-packages 2242 | '(which-key-posframe tabbar paredit olivetti org-wc markdown-preview-mode ac-clang git-gutter+ magit-todos magit flycheck dap-mode lsp-treemacs lsp-ui lsp-mode exec-path-from-shell org-roam-timestamps impatient-mode markdown-mode atomic-chrome tree-sitter-langs org-pomodoro dired-subtree yasnippet try avy-menu maxframe material-theme powerline better-defaults which-key focus dired-icon ace-window nlinum emojify electric-spacing 0xc dirvish org-noter-pdftools auctex org-bullets counsel multiple-cursors org-ref org-roam-bibtex rainbow-delimiters org-preview-html git-gutter-fringe org-roam-ui wc-mode org-drill 0blayout evil-textobj-tree-sitter use-package languagetool auto-complete))) 2243 | (custom-set-faces 2244 | ;; custom-set-faces was added by Custom. 2245 | ;; If you edit it by hand, you could mess it up, so be careful. 2246 | ;; Your init file should contain only one such instance. 2247 | ;; If there is more than one, they won't work right. 2248 | ) 2249 | --------------------------------------------------------------------------------