├── .gitignore ├── .nojekyll ├── CNAME ├── Justfile ├── LICENSE.txt ├── LICENSE_GPLv3.txt ├── README.md ├── early-init.el ├── emacs.html ├── emacs.org ├── index.html ├── init.el ├── modules ├── ace-window │ └── ace-window.el ├── avy │ └── avy.el ├── cargo.el ├── completion │ └── completion.el ├── dashboard │ └── dashboard.el ├── fonts │ └── fonts.el ├── general │ └── general.el ├── git.el ├── gptel │ └── gptel.el ├── just │ └── just.el ├── latin-words │ └── latin-words.el ├── lsp │ └── lsp.el ├── magit │ └── magit.el ├── markdown │ └── markdown.el ├── org │ ├── org-mode-unpackaged.el │ └── org.el ├── programming.el ├── python │ └── python.el ├── registers │ └── registers.el ├── rust │ └── rust.el ├── s3-publish │ └── s3-publish.el ├── sql │ └── sql.el ├── ssh-agent │ └── ssh-agent.el ├── svelte │ └── svelte.el ├── text-scale │ └── text-scale.el ├── theme │ └── theme.el ├── treesit │ └── treesit.el ├── vterm │ └── vterm.el └── which-key │ └── which-key.el └── theme ├── emacs.theme ├── icon └── emacs.ico ├── simple_dark.css └── simple_dark.theme /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | /history 3 | /places 4 | /recentf 5 | /elpa/ 6 | /eln-cache/ 7 | /.org-id-locations 8 | /custom.el 9 | /straight/ 10 | /export/ 11 | /.git 12 | .gitignore 13 | /export/hello.txt 14 | /transient/ 15 | \#* 16 | /.dap-breakpoints 17 | /.lsp-session* 18 | tree-sitter/ 19 | /tramp 20 | /.cache/ 21 | -------------------------------------------------------------------------------- /.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnigmaCurry/emacs/0fff807c42c527e3ecc5dfadd3662eff7cccc643/.nojekyll -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | emacs.rymcg.tech -------------------------------------------------------------------------------- /Justfile: -------------------------------------------------------------------------------- 1 | set export 2 | current_dir := `pwd` 3 | 4 | # Print this help message for the Justfile targets 5 | help: 6 | @just -l 7 | 8 | # Clean pacage cache 9 | clean: 10 | rm -rf straight eln-cache 11 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | License for: 2 | https://emacs.rymcg.tech 3 | https://github.com/EnigmaCurry/emacs 4 | 5 | PUBLIC DOMAIN LICENSE (0BSD) 6 | 7 | Permission to use, copy, modify, and/or distribute this software 8 | for any purpose with or without fee is hereby granted. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.[21] 18 | 19 | Some code in this distribution is specifically identified as being 20 | licensed GPLv3. If these files continue to be reproduced, the license 21 | of this entire distribution is modified to GPLv3: 22 | 23 | GNU GENERAL PUBLIC LICENSE 24 | Version 3, 29 June 2007 25 | 26 | Copyright 2025 EnigmaCurry 27 | 28 | This program is free software: you can redistribute it and/or modify 29 | it under the terms of the GNU General Public License as published by 30 | the Free Software Foundation, either version 3 of the License, or 31 | (at your option) any later version. 32 | 33 | This program is distributed in the hope that it will be useful, 34 | but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 36 | GNU General Public License for more details. 37 | 38 | You should have received a copy of the GNU General Public License 39 | along with this program. If not, see . 40 | -------------------------------------------------------------------------------- /LICENSE_GPLv3.txt: -------------------------------------------------------------------------------- 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 | # Modular GNU Emacs Configuration 2 | 3 | For my new config, see [emacs.rymcg.tech](https://emacs.rymcg.tech) 4 | 5 | ## Older configs 6 | 7 | Here's my previous config branch: 8 | [straight](https://github.com/enigmacurry/emacs/tree/straight) 9 | 10 | Here's my old [spacemacs config 11 | branch](https://github.com/EnigmaCurry/emacs/tree/spacemacs) 12 | 13 | Here's my old old [literate config 14 | branch](https://github.com/EnigmaCurry/emacs/blob/literate/config.org) 15 | 16 | If you want to see my old old old config from the late 2000s, see the 17 | [ancient-history 18 | branch](https://github.com/EnigmaCurry/emacs/tree/ancient-history) 19 | -------------------------------------------------------------------------------- /early-init.el: -------------------------------------------------------------------------------- 1 | ;; Load an initial theme (will be overriden later in modules/theme/theme.el) 2 | (load-theme 'modus-vivendi) 3 | ;; Set a larger default font size (150 = 15 pt size): 4 | (setq my/default-text-height 150) 5 | (set-face-attribute 'default nil :height my/default-text-height) 6 | ;; Turn off GUI distractions: 7 | (menu-bar-mode -1) ; Press F10 to bring up the menu if you still need it. 8 | (tool-bar-mode -1) 9 | (scroll-bar-mode -1) 10 | (setq inhibit-startup-screen t) 11 | ;; Don't resize the frame when adjusting the font size: 12 | (setq window-resize-pixelwise t) 13 | (setq frame-resize-pixelwise t) 14 | ;; Disable package.el in favor of straight.el 15 | (setq package-enable-at-startup nil) 16 | 17 | ;; Debug options: 18 | ;;; Start Emacs with the `--debug-init` argument, to debug errors during startup. 19 | ;;; Enter debugger on specific logger regex (see *Messages* buffer): 20 | ;; (setq debug-on-message "Example log message to trace") 21 | ;;; M-x toggle-debug-on-error 22 | ;;(setq debug-on-error t) 23 | (setq warning-minimum-level :error) 24 | -------------------------------------------------------------------------------- /emacs.html: -------------------------------------------------------------------------------- 1 | index.html -------------------------------------------------------------------------------- /emacs.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Modular GNU Emacs Configuration 2 | #+LANGUAGE: en 3 | #+PROPERTY: header-args :results none :eval yes 4 | #+SETUPFILE: theme/emacs.theme 5 | #+SETUPFILE: theme/simple_dark.theme 6 | #+OPTIONS: noweb:t 7 | 8 | * Configure your distribution here :noexport: 9 | :CUSTOM: 10 | 11 | If you are making this config your own, you must personalize all of 12 | the details in this section. There is some redundancy of values here! 13 | Make sure you edit *all* of the forms in this section. 14 | 15 | # Enter your name: 16 | #+AUTHOR: EnigmaCurry 17 | # Enter your URL to the HTML export of this config: 18 | #+LINK: web https://emacs.rymcg.tech 19 | # Enter your public git forge page for this config: 20 | #+LINK: git-repo https://github.com/EnigmaCurry/emacs 21 | # Enter your branch specific file blob URL for this config: 22 | #+LINK: git-blob https://github.com/EnigmaCurry/emacs/blob/literate-new 23 | 24 | (See the GitHub docs for the file blob URL standard: 25 | https://docs.github.com/en/repositories/working-with-files/using-files/getting-permanent-links-to-file) 26 | 27 | Enter your git repository here (again): 28 | #+name: git-repo 29 | #+begin_src 30 | https://github.com/EnigmaCurry/emacs 31 | #+end_src 32 | 33 | Enter just your git username in lower case: 34 | #+name: git-user-name 35 | #+begin_src 36 | enigmacurry 37 | #+end_src 38 | 39 | Enter just the repository name: 40 | #+name: git-repo-name 41 | #+begin_src 42 | emacs 43 | #+end_src 44 | 45 | :END: 46 | 47 | * Goals 48 | 49 | This is a new attempt at writing a depersonalized, copyable, and 50 | modular Emacs config: 51 | 52 | * All Emacs config (elisp) is written in a single Org Mode file: 53 | * Config repository: [[git-repo]] 54 | * Org source file: [[git-blob:/emacs.org?plain=1][emacs.org]] 55 | * You may [[git-repo:/fork][fork this repository]] to make it your own. 56 | * In case this config is already a fork, you may want to start 57 | with the original [[https://emacs.rymcg.tech][emacs.rymcg.tech]] instead. 58 | * Your configuration is displayed (exported) as a single HTML page: 59 | * Config page: [[web]] 60 | * This page is easy to search and requires no JavaScript. 61 | * All Org-Babel code blocks are [[https://orgmode.org/manual/Extracting-Source-Code.html]["tangled"]] into normal elisp files and 62 | published to the git repository: 63 | * [[git-blob:/emacs.org?plain=1][emacs.org]] remains the single "source of truth" of this config. 64 | * However, it is the tangled elisp files ([[git-blob:/init.el][init.el]], [[git-blob:/modules][modules/*]]) that 65 | Emacs loads on startup, not emacs.org. 66 | * All of the other files in the repository will be overwritten each 67 | time emacs.org is re-tangled. 68 | * Code blocks should be of medium size, grouping related functions: 69 | * There should be more code here than prose. Avoid having lots of 70 | little code blocks and excessive explanations. 71 | * All custom elisp functions and variables should have the namespace 72 | prefix =my/= : 73 | * This configuration is non-proprietary to promote code adoption 74 | by others. 75 | * Meme: [[https://ec-share.nyc3.digitaloceanspaces.com/i-made-this-1.jpg]["I made this"]]. 76 | * This config should support multiple platforms: Linux 77 | CLI, Wayland, Android... 78 | * Most configuration should be customizable by the user without 79 | needing to edit this file: 80 | * Run =M-x my/custom-settings= to open the configuration menu to 81 | save settings on a per-installation basis in 82 | =~/.emacs.d/custom.el= (and it is =.gitignore= 'd). 83 | * The base config should work without needing to download any third 84 | party libraries: 85 | * The custom variable =my/machine-labels= is used to set 86 | per-machine labels that opt-in to loading additional modules. 87 | * LICENSE 88 | 89 | See [[file:LICENSE.txt]] 90 | 91 | See [[file:LICENSE_GPLv3.txt]] 92 | 93 | This distribution has a *mixed license* (0BSD and GPLv3). Everything 94 | here that has not been identified in the comments as having been taken 95 | from somewhere else, is licensed/dedicated to you as public domain 96 | (0BSD). Some code has been copied from other sources that are licensed 97 | GPLv3 and so these have been identified as such in the code block 98 | comments. As long as these additional sources are included in this 99 | distribution, this repository is effectively (infectively) licensed as 100 | GPLv3. 101 | 102 | #+begin_src text :noweb yes :tangle "LICENSE.txt" :exports none 103 | License for: 104 | https://emacs.rymcg.tech 105 | https://github.com/EnigmaCurry/emacs 106 | 107 | PUBLIC DOMAIN LICENSE (0BSD) 108 | 109 | Permission to use, copy, modify, and/or distribute this software 110 | for any purpose with or without fee is hereby granted. 111 | 112 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 113 | WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 114 | WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 115 | AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 116 | CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 117 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 118 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 119 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.[21] 120 | 121 | Some code in this distribution is specifically identified as being 122 | licensed GPLv3. If these files continue to be reproduced, the license 123 | of this entire distribution is modified to GPLv3: 124 | 125 | GNU GENERAL PUBLIC LICENSE 126 | Version 3, 29 June 2007 127 | 128 | Copyright 2025 EnigmaCurry 129 | 130 | This program is free software: you can redistribute it and/or modify 131 | it under the terms of the GNU General Public License as published by 132 | the Free Software Foundation, either version 3 of the License, or 133 | (at your option) any later version. 134 | 135 | This program is distributed in the hope that it will be useful, 136 | but WITHOUT ANY WARRANTY; without even the implied warranty of 137 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138 | GNU General Public License for more details. 139 | 140 | You should have received a copy of the GNU General Public License 141 | along with this program. If not, see . 142 | #+end_src 143 | 144 | * Dependencies 145 | ** Emacs 146 | You will need a recent version of Emacs. 147 | 148 | #+begin_src shell 149 | #e.g., on Fedora: 150 | sudo dnf install emacs 151 | #+end_src 152 | 153 | #+begin_src emacs-lisp :results replace :exports both 154 | (message (emacs-version)) 155 | #+end_src 156 | 157 | 158 | ** Build dependencies 159 | 160 | #+begin_src 161 | #e.g., on Fedora: 162 | sudo dnf install cmake libtool openssl-devel 163 | #+end_src 164 | 165 | ** Rustup and Cargo 166 | 167 | [[https://rustup.rs/][Rustup]] is a tool that installs the latest versions of [[https://www.rust-lang.org/][Rust]] and [[https://doc.rust-lang.org/cargo/][Cargo]] 168 | /in your home directory/. Cargo is a user-space source-package manager 169 | for Rust programs and libraries. This config uses Cargo to install the 170 | optional helper programs used by its modules. Once setup, any 171 | user-space packages installed by Cargo are placed in =~/.cargo/bin=. 172 | 173 | You may be able to find the =rustup= tool in your system package 174 | manager and install it that way: 175 | 176 | #+begin_src shell 177 | # e.g., on Fedora: 178 | sudo dnf install rustup 179 | rustup-init 180 | rustup component add rust-analyzer 181 | #+end_src 182 | 183 | But you can also [[https://rustup.rs/][install it]] the "curl bomb" way on most other systems: 184 | 185 | #+begin_src shell 186 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 187 | rustup component add rust-analyzer 188 | #+end_src 189 | 190 | Cargo packages are declared by Emacs modules themselves: 191 | 192 | #+begin_src emacs-lisp 193 | ;; this example declares the "just" crate needs to be installed. 194 | ;; (the actual install is deferred until later): 195 | (my/cargo-dependency "just") 196 | #+end_src 197 | 198 | All of the crates are installed together [[#cargo-install-my-cargo-dependencies][/after/ all of the modules 199 | have been loaded]]. 200 | 201 | ** Git 202 | 203 | Install =git= via your package manager: 204 | 205 | #+begin_src shell 206 | #e.g., Fedora: 207 | sudo dnf install git 208 | #+end_src 209 | 210 | Clone this git repository: 211 | 212 | #+begin_src shell :noweb yes 213 | git clone <>.git \ 214 | ~/git/vendor/<>/<> 215 | #+end_src 216 | 217 | Switch to the right branch: 218 | 219 | #+begin_src emacs-lisp :results replace :exports results 220 | (message "git checkout %s" (my/emacs-git-branch)) 221 | #+end_src 222 | *** Function to get the current git branch :noexport: 223 | #+begin_src emacs-lisp :tangle "modules/git.el" :mkdirp yes 224 | ;;; function to determine the current git branch -- ignore this in context 225 | (defun my/emacs-git-branch () 226 | (substring (shell-command-to-string "git branch --show-current") 0 -1)) 227 | #+end_src 228 | ** Tree-sitter 229 | Tree-sitter is an optional dependency. It adds advanced syntax tree 230 | parser to language modes. 231 | 232 | #+begin_src shell 233 | #on e.g., Fedora 234 | sudo dnf install libtree-sitter 235 | #+end_src 236 | 237 | ** Create your Emacs config directory 238 | 239 | You can try this config out without modifying your existing config. 240 | The following command tells Emacs to load config directly (ignoring 241 | your existing config): 242 | 243 | #+begin_src shell :noweb yes 244 | emacs --init-directory ~/git/vendor/<>/<> 245 | #+end_src 246 | 247 | If you omit =--init-directory=, the default location Emacs looks for 248 | your config is =~/.emacs.d= 249 | 250 | To set this config as the default, symlink the git repository from 251 | =~/.emacs.d= : 252 | 253 | #+begin_src shell :noweb yes 254 | ln -s ~/git/vendor/<>/<> ~/.emacs.d 255 | #+end_src 256 | 257 | Now when you run =emacs= with no arguments it will load the =init.el= 258 | found in the git repository. 259 | 260 | * Early Init 261 | 262 | The [[file:early-init.el]] is the first config file that is loaded on 263 | Emacs startup. It is used to set an initial visual look and feel 264 | before the GUI is initialized, including an initial dark theme. 265 | Additionally, early debug options are set here. 266 | 267 | #+begin_src emacs-lisp :tangle "early-init.el" 268 | ;; Load an initial theme (will be overriden later in modules/theme/theme.el) 269 | (load-theme 'modus-vivendi) 270 | ;; Set a larger default font size (150 = 15 pt size): 271 | (setq my/default-text-height 150) 272 | (set-face-attribute 'default nil :height my/default-text-height) 273 | ;; Turn off GUI distractions: 274 | (menu-bar-mode -1) ; Press F10 to bring up the menu if you still need it. 275 | (tool-bar-mode -1) 276 | (scroll-bar-mode -1) 277 | (setq inhibit-startup-screen t) 278 | ;; Don't resize the frame when adjusting the font size: 279 | (setq window-resize-pixelwise t) 280 | (setq frame-resize-pixelwise t) 281 | ;; Disable package.el in favor of straight.el 282 | (setq package-enable-at-startup nil) 283 | 284 | ;; Debug options: 285 | ;;; Start Emacs with the `--debug-init` argument, to debug errors during startup. 286 | ;;; Enter debugger on specific logger regex (see *Messages* buffer): 287 | ;; (setq debug-on-message "Example log message to trace") 288 | ;;; M-x toggle-debug-on-error 289 | ;;(setq debug-on-error t) 290 | (setq warning-minimum-level :error) 291 | #+end_src 292 | 293 | * Base config 294 | 295 | This is the base config of [[file:init.el]] which is loaded in all 296 | environments. Only Emacs builtins will be allowed here: 297 | 298 | ** Core libraries 299 | 300 | #+begin_src emacs-lisp :tangle "init.el" 301 | ;; core libraries 302 | (require 'cl-lib) 303 | #+end_src 304 | 305 | ** Nice defaults 306 | 307 | #+begin_src emacs-lisp :tangle "init.el" 308 | ;; Nice defaults 309 | (setq-default confirm-kill-emacs #'yes-or-no-p) 310 | (setq-default vc-follow-symlinks t) 311 | (setq-default indicate-empty-lines t) 312 | (setq-default indicate-buffer-boundaries 'left) 313 | (setq-default sentence-end-double-space nil) 314 | (setq-default indent-tabs-mode nil) 315 | (setq-default tab-width 4) 316 | (setq-default visible-bell t) 317 | (setq-default dired-listing-switches "-al --group-directories-first") 318 | (setq-default tramp-default-method "ssh") 319 | (setq-default native-comp-deferred-compilation-deny-list nil) 320 | (setq-default browse-url-browser-function 'browse-url-firefox) 321 | (setq-default require-final-newline t) 322 | (put 'narrow-to-region 'disabled nil) 323 | (put 'downcase-region 'disabled nil) 324 | (put 'upcase-region 'disabled nil) 325 | #+end_src 326 | 327 | ** Configure file backups and auto-saves 328 | 329 | * Store file backups in =~/.emacs.d/backup= rather than being 330 | littered everywhere else. Backups should store a file snapshot 331 | before /every/ save. 332 | * Store auto-saves in =~/.emacs.d/auto-save=. auto-saves helps you to 333 | not to lose your work /before/ you save, by automatically saving 334 | idle buffers into the auto-save directory. 335 | 336 | #+begin_src emacs-lisp :tangle "init.el" 337 | ;; Backups and auto-save 338 | ;; Reference: https://www.emacswiki.org/emacs/BackupDirectory 339 | ;; Reference: https://www.emacswiki.org/emacs/ForceBackups 340 | (setq backup-by-copying t) 341 | (setq backup-directory-alist 342 | `(("." . ,(expand-file-name "backup" user-emacs-directory)))) 343 | (setq delete-old-versions t) 344 | (setq kept-new-versions 6) 345 | (setq kept-old-versions 2) 346 | (setq version-control t) 347 | (setq vc-make-backup-files t) 348 | (add-hook 'before-save-hook 349 | (lambda () (setq buffer-backed-up nil))) 350 | ;; autosaves go in a separate directory 351 | (let ((auto-save-dir (expand-file-name "auto-save" user-emacs-directory))) 352 | (make-directory auto-save-dir t) 353 | (setq auto-save-file-name-transforms 354 | `((".*" ,auto-save-dir t)))) 355 | #+end_src 356 | 357 | ** Customization 358 | 359 | Emacs has a powerful [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Easy-Customization.html][customization feature]] and this configuration uses 360 | it for all the user and machine specific settings. 361 | 362 | Enter the interactive customization menu for this config: =M-x 363 | my/custom-settings= 364 | 365 | There are several sub-menus of settings for different modules. You can 366 | change the values for any of the settings and then press =C-x C-s= 367 | (custom-save), and it will save the custom values in 368 | =~/.emacs.d/custom.el=. This file is ignored by the git repository, 369 | and it is used to store persistent custom values for a specific 370 | machine only. 371 | 372 | #+begin_src emacs-lisp :tangle "init.el" 373 | ;; Store customizations in custom.el 374 | (setq custom-file (locate-user-emacs-file "custom.el")) 375 | (when (file-exists-p custom-file) 376 | (load custom-file)) 377 | ;; Store all customizations under my/custom-settings group 378 | (defgroup my/custom-settings nil 379 | "My custom Emacs settings" 380 | :group 'emacs) 381 | ;; Shortcut to open custom settings: 382 | (defun my/custom-settings () 383 | "Open the Emacs customization interface for my custom settings." 384 | (interactive) 385 | (customize-group 'my/custom-settings)) 386 | (defalias 'my/settings 'my/custom-settings) 387 | #+end_src 388 | 389 | ** Builtin minor modes to activate everywhere 390 | 391 | #+begin_src emacs-lisp :tangle "init.el" 392 | ;; Global minor modes 393 | (column-number-mode) 394 | (save-place-mode t) 395 | (savehist-mode t) 396 | (recentf-mode t) 397 | (electric-pair-mode t) 398 | #+end_src 399 | ** PATH setup 400 | #+begin_src emacs-lisp :tangle "init.el" :mkdirp yes 401 | ;; Function to add a directory to PATH and exec-path 402 | (defun my/add-exec-path (dir) 403 | "Add DIR to the environment PATH and exec-path if not already present." 404 | (unless (member dir exec-path) 405 | (setenv "PATH" (concat dir path-separator (getenv "PATH"))) 406 | (add-to-list 'exec-path dir))) 407 | #+end_src 408 | ** Programming mode 409 | 410 | #+begin_src emacs-lisp :tangle "modules/programming.el" :mkdirp yes 411 | ;; Basic programming mode settings 412 | (setq-default display-fill-column-indicator-column 80) 413 | (add-hook 'prog-mode-hook (lambda () 414 | (setq show-trailing-whitespace t) 415 | (display-fill-column-indicator-mode 1) 416 | (display-line-numbers-mode 1))) 417 | 418 | ;; Edit .env files with shell-script-mode 419 | (add-to-list 'auto-mode-alist '("\\.env\\'" . shell-script-mode)) 420 | (add-to-list 'auto-mode-alist '("\\.env_.*\\'" . shell-script-mode)) 421 | (add-to-list 'auto-mode-alist '("\\.env-dist\\'" . shell-script-mode)) 422 | #+end_src 423 | 424 | ** Shell processes 425 | #+begin_src emacs-lisp :tangle "init.el" 426 | (defun my/shell-execute (command &optional interactive) 427 | "Run a given shell COMMAND in a new buffer and display its output." 428 | (interactive) 429 | (let* ((command-name (car (split-string command))) 430 | (buffer-name (generate-new-buffer-name (concat "*" command-name " Output*"))) 431 | (buffer (get-buffer-create buffer-name))) 432 | (with-current-buffer buffer 433 | (erase-buffer) 434 | (insert "## Running shell process ...\n")) 435 | (start-process-shell-command 436 | command 437 | buffer 438 | command) 439 | (pop-to-buffer buffer))) 440 | #+end_src 441 | * Cargo 442 | 443 | [[https://doc.rust-lang.org/cargo/][Cargo]] is used to install some system programs automatically. 444 | 445 | ** Set cargo binary PATH 446 | 447 | Cargo and all of the helper programs you install go in =~/.cargo/bin=. 448 | Ensure that this path is set (because Emacs might not have read 449 | =~/.bashrc=): 450 | 451 | #+begin_src emacs-lisp :tangle "modules/cargo.el" :mkdirp yes 452 | (my/add-exec-path "~/.cargo/bin") 453 | (unless (executable-find "cargo") 454 | (message "cargo binary NOT found.")) 455 | #+end_src 456 | 457 | ** Cargo functions 458 | 459 | #+begin_src emacs-lisp :tangle "modules/cargo.el" 460 | (require 'seq) 461 | (require 'comint) 462 | 463 | (defun my/cargo-package-installed-p (package) 464 | "Check if a given cargo PACKAGE is installed. 465 | PACKAGE can be either a string or a cons cell (CRATE . GIT-URL). 466 | In either case, this function uses the crate name for the check." 467 | (let ((pkg (if (consp package) (car package) package))) 468 | (with-temp-buffer 469 | (when (eq 0 (call-process "cargo" nil t nil "install" "--list")) 470 | (goto-char (point-min)) 471 | (search-forward pkg nil t))))) 472 | (defun my/cargo-install (programs) 473 | "Install a list of PROGRAMS via `cargo install`, skipping those already installed. 474 | PROGRAMS can be: 475 | - a single string (with space-separated program names), 476 | - a list of strings, 477 | - or a list where some elements are cons cells (CRATE . GIT-REPO). 478 | 479 | For cons cell entries, Cargo is invoked with the --git flag." 480 | (unless programs 481 | (user-error "No programs specified for cargo install")) 482 | ;; If PROGRAMS is a string, split it into a list. 483 | (setq programs (if (stringp programs) 484 | (split-string programs) 485 | programs)) 486 | ;; Remove already installed programs. 487 | (setq programs (seq-remove #'my/cargo-package-installed-p programs)) 488 | ;; Separate into two groups: 489 | ;; - crates from crates.io (plain strings or cons cells treated as a name only) 490 | ;; - git dependencies (explicit cons cells) 491 | (let ((crate-names (mapcar (lambda (dep) 492 | (if (consp dep) 493 | (car dep) 494 | dep)) 495 | (seq-filter (lambda (dep) 496 | (not (consp dep))) 497 | programs))) 498 | (git-deps (seq-filter #'consp programs))) 499 | ;; Install crates from crates.io in one command, if any. 500 | (when crate-names 501 | (let ((command (concat "cargo install " (string-join crate-names " ")))) 502 | (my/shell-execute command))) 503 | ;; Install each git dependency separately. 504 | (dolist (dep git-deps) 505 | (let* ((crate (car dep)) 506 | (git-repo (cdr dep)) 507 | (command (format "cargo install %s --git %s" crate git-repo))) 508 | (my/shell-execute command))))) 509 | (defvar my/cargo-dependencies nil 510 | "A list of Rust crate dependencies to be installed. 511 | Each dependency is either a crate name (a symbol or string) or a cons cell 512 | of the form (CRATE . GIT-REPO).") 513 | 514 | (defun my/cargo-dependency (crate &optional git-repo) 515 | "Add a Rust CRATE to the list of dependencies. 516 | If GIT-REPO is provided, the dependency is stored as (CRATE . GIT-REPO). 517 | Otherwise, only CRATE is stored. 518 | If the dependency (by crate name) already exists, do nothing." 519 | (unless (cl-find crate my/cargo-dependencies 520 | :test (lambda (d c) 521 | (if (consp d) 522 | (equal (car d) c) 523 | (equal d c)))) 524 | (push (if git-repo (cons crate git-repo) crate) 525 | my/cargo-dependencies))) 526 | #+end_src 527 | ** Justfile 528 | 529 | [[https://github.com/casey/just][Just]] is better than Make. 530 | 531 | #+begin_src emacs-lisp :tangle "modules/just/just.el" :mkdirp yes 532 | ;; depend on the just crate so its installed automatically 533 | ;; you must add "just" to the list of my/machine-labels for this to work: 534 | (my/cargo-dependency "just") 535 | #+end_src 536 | 537 | This =Justfile= consolidates commands that operate 538 | on this git repository: 539 | 540 | #+begin_src text :tangle Justfile 541 | set export 542 | current_dir := `pwd` 543 | 544 | # Print this help message for the Justfile targets 545 | help: 546 | @just -l 547 | 548 | # Clean pacage cache 549 | clean: 550 | rm -rf straight eln-cache 551 | #+end_src 552 | 553 | |-------------------------------------| 554 | | Clean package cache (shell command) | 555 | | =just clean= | 556 | 557 | * straight.el and use-package 558 | 559 | [[https://github.com/radian-software/straight.el][straight.el]] replaces the builtin package manager of Emacs 560 | ([[https://github.com/emacs-mirror/emacs/blob/master/lisp/emacs-lisp/package.el][package.el]]). In return, you can install packages directly from git, 561 | and lock dependencies for reproducible installs. [[https://github.com/jwiegley/use-package][use-package]] is an 562 | Emacs builtin macro that enables declarative package configuration. 563 | 564 | ** Lazy-load straight.el 565 | 566 | #+begin_src emacs-lisp :tangle "init.el" 567 | (defun my/bootstrap-straight (&rest _) 568 | "Bootstrap straight.el only if it's not already installed." 569 | (unless (bound-and-true-p straight--build-dir) 570 | (let ((bootstrap-file 571 | (expand-file-name "straight/repos/straight.el/bootstrap.el" 572 | user-emacs-directory)) 573 | (bootstrap-version 5)) 574 | (unless (file-exists-p bootstrap-file) 575 | (with-current-buffer 576 | (url-retrieve-synchronously 577 | "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" 578 | 'silent 579 | 'inhibit-cookies) 580 | (goto-char (point-max)) 581 | (eval-print-last-sexp) 582 | )) 583 | (load bootstrap-file nil 'nomessage) 584 | (setq straight-use-package-by-default t) 585 | (straight-use-package 'use-package)))) 586 | ;; Advise `use-package` to initialize straight.el when first called 587 | (advice-add 'use-package :before #'my/bootstrap-straight) 588 | #+end_src 589 | ** Track packages added via use-package 590 | 591 | #+begin_src emacs-lisp :tangle "init.el" 592 | (defvar my/use-package-tracked-list nil 593 | "A list to track the names of packages declared via `use-package`.") 594 | (defun my/use-package-tracked-list () 595 | "Display the tracked `use-package` packages in a new buffer, one per line. 596 | If the buffer already exists, delete it and recreate it." 597 | (interactive) 598 | (let ((buffer-name "*Tracked Packages*")) 599 | (when (get-buffer buffer-name) 600 | (kill-buffer buffer-name)) 601 | (let ((buffer (get-buffer-create buffer-name))) 602 | (with-current-buffer buffer 603 | (erase-buffer) 604 | (insert "# Packages tracked via use-package:\n") 605 | (if my/use-package-tracked-list 606 | (dolist (pkg (sort my/use-package-tracked-list #'string<)) 607 | (insert (format "%s\n" pkg))) 608 | (insert "No packages tracked.\n")) 609 | (read-only-mode 1)) 610 | (pop-to-buffer buffer)))) 611 | (defun my/use-package-advice (orig-fun &rest args) 612 | "Advice around `use-package' to track package names." 613 | (when (symbolp (car args)) 614 | (push (symbol-name (car args)) my/use-package-tracked-list) 615 | (setq my/use-package-tracked-list (delete-dups my/use-package-tracked-list))) 616 | (apply orig-fun args)) 617 | 618 | (advice-add 'use-package :around #'my/use-package-advice) 619 | #+end_src 620 | 621 | * Configure which modules to load 622 | 623 | A modular Emacs configuration is designed to serve various roles 624 | running in several different environments. The base config is kept 625 | lean, without any third party modules loaded. Each machine may be 626 | labeled with the names of additional modules to load. 627 | 628 | #+begin_src emacs-lisp :tangle "init.el" 629 | ;; Customize which emacs config modules to load on a per-machine basis: 630 | (defcustom my/machine-labels '() 631 | "List of machine-specific labels to configure which modules to load." 632 | :type '(repeat string) 633 | :group 'my/custom-settings) 634 | (defun my/machine-labels () 635 | "Return the list of machine-specific labels." 636 | (interactive) 637 | my/machine-labels) 638 | (defun my/machine-has-label (label) 639 | "Check if the current machine is labeled with LABEL." 640 | (if (member label my/machine-labels) 641 | t 642 | nil)) 643 | (defun my/machine-labels-available () 644 | "List all available machine labels" 645 | (let ((modules-dir (expand-file-name "modules" user-emacs-directory))) 646 | (cl-sort (mapcar #'file-name-nondirectory 647 | (seq-filter #'file-directory-p 648 | (directory-files modules-dir t "^[^.]" t))) #'string<))) 649 | (defun my/machine-labels-enable-all nil 650 | "Adds ALL existing machine labels to the custom my/machine-labels" 651 | (interactive) 652 | (let ((modules-dir (expand-file-name "modules" user-emacs-directory))) 653 | (when (y-or-n-p (format "Do you want to enable ALL Emacs modules from %s? " modules-dir)) 654 | (progn 655 | (customize-set-variable 'my/machine-labels (my/machine-labels-available)) 656 | (customize-save-customized))))) 657 | #+end_src 658 | 659 | Here are the [[https://github.com/EnigmaCurry/emacs/tree/literate-new/modules][available modules]]: 660 | 661 | #+begin_src emacs-lisp :results value replace :exports results 662 | (mapconcat (lambda (x) (format "- %s" x)) (my/machine-labels-available) "\n") 663 | #+end_src 664 | 665 | *All modules are disabled by default! You must customize 666 | =my/machine-labels= on each machine you configure.* 667 | 668 | |--------------------------| 669 | | =M-x my/custom-settings= | 670 | 671 | This will open the customization interface allowing you to set the 672 | list named =My Machine Labels=. For example, add each of the labels 673 | you want to enable for the current machine: =general=, =org=, 674 | =markdown=, etc: 675 | 676 | #+begin_src example 677 | ↓ My Machine Labels: 678 | Repeat: 679 | INS DEL String: general 680 | INS DEL String: org 681 | INS DEL String: markdown 682 | INS 683 | State : SAVED and set. 684 | List of machine-specific labels to configure which modules to load. 685 | #+end_src 686 | 687 | When done, press =C-x C-s= to save the settings. 688 | 689 | If you want to enable ALL existing modules, you can run =M-x 690 | my/machine-labels-enable-all= (the result will be saved in 691 | =custom.el=). (If new modules are added to the git repository, they 692 | will not be enabled until you run this again, or by customizing 693 | =my/machine-labels=.) 694 | 695 | You can then remove any of the modules you don't want, the same way as 696 | before: =M-x my/custom-settings=. 697 | 698 | You should restart Emacs to reload the configured modules from 699 | =custom.el=. 700 | 701 | * Modules 702 | ** Registers (label =registers=) 703 | 704 | Registers are storage compartments in Emacs, which can hold several 705 | different types of things: strings, numbers, buffer positions, frame 706 | configs, etc. 707 | 708 | *** Position registers 709 | 710 | [[info:emacs#Position Registers][Position Registers]] store the point position of buffers, so you can 711 | quickly come back to it from anywhere. 712 | 713 | * =C-c j e= jump to the Emacs config file (=emacs.org=) 714 | * =C-c j o= jump to the user Org notes directory (=my/org-notes-directory=) 715 | * =C-c j g= open the user's git directory (You must customize =my/git-user-directory=) 716 | * =C-c j v= open the vendor git directory (You may customize =my/git-vendor-directory=) 717 | * =C-c j d= open the Docker projects directory ([[https://github.com/EnigmaCurry/d.rymcg.tech][d.rymcg.tech]]) 718 | 719 | You should change the following values to suit your own environment by 720 | running =M-x my/custom-settings=. Enter the =My Path Settings= 721 | sub-menu, and change the following settings: 722 | 723 | * =my/git-vendor-directory= Set this to where you clone git 724 | repositories (not necessarily your own. e.g., =~/git/vendor=). 725 | * =my/git-user-directory= Set this to the directory where you store 726 | your /personal/ git repositories (e.g., 727 | =~/git/vendor/YOUR_USERNAME=). 728 | 729 | #+begin_src emacs-lisp :noweb yes :tangle "modules/registers/registers.el" :mkdirp yes 730 | (defgroup my/path-settings nil 731 | "My custom path settings" 732 | :group 'my/custom-settings) 733 | (defcustom my/git-vendor-directory "~/git/vendor" 734 | "My git vendor directory" 735 | :type 'string 736 | :group 'my/path-settings) 737 | (defcustom my/git-user-directory "~/git/vendor/<>" 738 | "My personal git repositories directory" 739 | :type 'string 740 | :group 'my/path-settings) 741 | 742 | (set-register ?e `(file . ,(expand-file-name "emacs.org" user-emacs-directory))) 743 | (set-register ?o `(file . ,my/org-notes-directory)) 744 | (set-register ?g `(file . ,my/git-user-directory)) 745 | (set-register ?d `(file . ,(expand-file-name "enigmacurry/d.rymcg.tech/" my/git-vendor-directory))) 746 | (set-register ?v `(file . ,my/git-vendor-directory)) 747 | #+end_src 748 | 749 | The =F1=, =F2=, =F3=, and =F4= keys store temporary positions: 750 | 751 | * =C-= jump to register stored in the F1 register. 752 | * =C-= jump to register stored in the F2 register. 753 | * =C-= jump to register stored in the F3 register. 754 | * =C-= jump to register stored in the F4 register. 755 | * =M-= store the current point into the F1 register. 756 | * =M-= store the current point into the F2 register. 757 | * =M-= store the current point into the F3 register. 758 | * =M-= store the current point into the F4 register. 759 | 760 | #+begin_src emacs-lisp :tangle "modules/registers/registers.el" :mkdirp yes 761 | (defun my/register-save-f1 () (interactive) (point-to-register 'my/register-f1)) 762 | (defun my/register-jump-f1 () (interactive) (jump-to-register 'my/register-f1)) 763 | (defun my/register-save-f2 () (interactive) (point-to-register 'my/register-f2)) 764 | (defun my/register-jump-f2 () (interactive) (jump-to-register 'my/register-f2)) 765 | (defun my/register-save-f3 () (interactive) (point-to-register 'my/register-f3)) 766 | (defun my/register-jump-f3 () (interactive) (jump-to-register 'my/register-f3)) 767 | (defun my/register-save-f4 () (interactive) (point-to-register 'my/register-f4)) 768 | (defun my/register-jump-f4 () (interactive) (jump-to-register 'my/register-f4)) 769 | #+end_src 770 | 771 | ** Theme (label =theme=) 772 | 773 | * [[https://github.com/myTerminal/theme-looper][theme-looper]] 774 | * [[https://github.com/hlissner/emacs-solaire-mode][solaire-mode]] 775 | * [[https://github.com/emacsfodder/emacs-deep-thought-theme][deep-thought]] 776 | 777 | You can cycle the current theme via =C-= and =C-=. As you do 778 | this, the theme will be made persistent by automatically customizing 779 | =my/theme= which is loaded on startup. 780 | 781 | #+begin_src emacs-lisp :tangle "modules/theme/theme.el" :mkdirp yes 782 | (defgroup my/theme-settings nil 783 | "My custom theme settings" 784 | :group 'my/custom-settings) 785 | (defcustom my/theme 'deeper-blue 786 | "Emacs Theme" 787 | :type 'symbol 788 | :group 'my/theme-settings) 789 | 790 | (defun my/theme-update (theme-fn) 791 | "Update the `my/theme` variable with the new theme and call THEME-FN." 792 | (let ((current-theme (car custom-enabled-themes))) 793 | (funcall theme-fn) 794 | (customize-set-variable 'my/theme (car custom-enabled-themes)) 795 | (customize-save-customized) 796 | (message "Theme changed to: %s" my/theme))) 797 | 798 | ;; Install themes directly from a git repository: 799 | ;;;NOTE: don't use deep-thought-theme it crashes Emacs 29.4!! 800 | ;;;Keeping this here as an example for loading a theme from git: 801 | ;; (use-package 802 | ;; deep-thought-theme 803 | ;; :straight 804 | ;; (deep-thought-theme :type git :repo "https://github.com/emacsfodder/emacs-deep-thought-theme.git")) 805 | (use-package solaire-mode :init (solaire-global-mode +1)) 806 | (use-package theme-looper 807 | :general 808 | ("C-" (lambda () (interactive) (my/theme-update 'theme-looper-enable-previous-theme))) 809 | ("C-" (lambda () (interactive) (my/theme-update 'theme-looper-enable-next-theme)))) 810 | 811 | (load-theme my/theme t) 812 | #+end_src 813 | ** Fonts (label =fonts=) 814 | *** List installed font families 815 | #+begin_src emacs-lisp :results replace 816 | (mapconcat (lambda (x) (format "- %s" x)) 817 | (delete-dups (sort (font-family-list) #'string<)) "\n") 818 | #+end_src 819 | 820 | *** Install font: JetBrains Mono Nerdfont 821 | 822 | [[https://www.jetbrains.com/lp/mono/][JetBrains Mono typeface]] 823 | [[https://www.nerdfonts.com/font-downloads][Nerd Fonts]] 824 | 825 | #+begin_src emacs-lisp :tangle "modules/fonts/fonts.el" :mkdirp yes 826 | ;;; Download JetBrains Mono typeface 827 | (let* ((url "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.3.0/JetBrainsMono.zip") 828 | (zip-file (expand-file-name "JetBrainsMono.zip" temporary-file-directory)) 829 | (font-dir (expand-file-name "~/.local/share/fonts/JetBrainsMonoNerdFont/")) 830 | (default-directory temporary-file-directory)) 831 | (unless (file-directory-p font-dir) 832 | (url-copy-file url zip-file t) 833 | (make-directory font-dir t) 834 | (let ((output-buffer (generate-new-buffer "*unzip-output*"))) 835 | (unwind-protect 836 | (call-process "unzip" 837 | nil output-buffer nil "-j" zip-file "-d" font-dir) 838 | (kill-buffer output-buffer))) 839 | (call-process "fc-cache" nil nil nil "-fv") 840 | (delete-file zip-file) 841 | (message "JetBrains Mono Nerd Font installed successfully."))) 842 | #+end_src 843 | *** Set font faces 844 | #+begin_src emacs-lisp :tangle "modules/fonts/fonts.el" :mkdirp yes 845 | ;;; show list of installed fonts: 846 | ;;(font-family-list) 847 | ;;; show default font: 848 | ;;(face-attribute 'default :font) 849 | ;;; Set default font faces: 850 | ;; M-x my/custom-settings :: font-settings group: 851 | (defgroup my/font-settings nil 852 | "My custom font settings" 853 | :group 'my/custom-settings) 854 | (defcustom my/font-family-default "JetBrainsMono Nerd Font" 855 | "Default font family" 856 | :type 'string 857 | :group 'my/font-settings) 858 | (defcustom my/font-size-default 120 859 | "Default font size" 860 | :type 'string 861 | :group 'my/font-settings) 862 | (defun my/font-settings-apply () 863 | "Set the default font based on 864 | `my/font-family-default` and `my/font-size-default`." 865 | (set-face-attribute 'default nil 866 | :family my/font-family-default 867 | :height my/font-size-default) 868 | t) 869 | (my/font-settings-apply) 870 | (add-hook 'after-init-hook #'my/font-settings-apply) 871 | (advice-add 'custom-save-all :after (lambda () 872 | "Re-apply custom settings after saving customizations." 873 | (my/font-settings-apply))) 874 | 875 | ;; Use nerd icons 876 | (use-package nerd-icons 877 | :custom 878 | (nerd-icons-font-family "JetBrainsMono Nerd Font")) 879 | #+end_src 880 | 881 | Run =M-x my/custom-settings= and go to the font customize sub-menu. 882 | Choose your default font family and font size for your machine. Use 883 | =M-x describe-char= and =M-x describe-font= to help debug font 884 | selection. 885 | 886 | *** Preview fonts 887 | 888 | * [[https://protesilaos.com/emacs/show-font][show-font]] 889 | 890 | #+begin_src emacs-lisp :tangle "modules/fonts/fonts.el" :mkdirp yes 891 | (use-package show-font) 892 | #+end_src 893 | 894 | #+begin_src emacs-lisp 895 | (setq show-font-pangram 896 | (concat "A wizard’s job is to vex chumps quickly in fog." 897 | "\n\t٩(-̮̮̃-̃)۶ ٩(●̮̮̃•̃)۶ ٩(͡๏̯͡๏)۶ ٩(-̮̮̃•̃)." 898 | "\n\tΣὲ γνωρίζω ἀπὸ τὴν κόψη")) 899 | (show-font-list) 900 | #+end_src 901 | ** General keybindings manager (label =general=) 902 | 903 | * [[https://github.com/noctuid/general.el?tab=readme-ov-file#readme][general.el]] 904 | 905 | #+begin_src emacs-lisp :tangle "modules/general/general.el" :mkdirp yes 906 | (use-package 907 | general 908 | :init 909 | ;; Switch between two most recent buffers: 910 | (fset 'quick-switch-buffer [?\C-x ?b return]) 911 | :config 912 | ;;; Custom global bindings: 913 | (general-define-key 914 | "C-h B" 'general-describe-keybindings 915 | "s-b" 'quick-switch-buffer 916 | "s-B" 'buffer-menu-other-window 917 | "C-x B" 'buffer-menu-other-window 918 | "s-o" 'browse-url 919 | "C-;" 'comment-region ; C-u C-; to uncomment 920 | "s-" 'mouse-drag-region-rectangle 921 | "C-x j" 'jump-to-register 922 | "C-c j" 'jump-to-register 923 | "C-" 'my/register-jump-f1 924 | "M-" 'my/register-save-f1 925 | "C-" 'my/register-jump-f2 926 | "M-" 'my/register-save-f2 927 | "C-" 'my/register-jump-f3 928 | "M-" 'my/register-save-f3 929 | "C-" 'my/register-jump-f4 930 | "M-" 'my/register-save-f4 931 | ) 932 | ;;; Put the Emacs default keybindings you want included 933 | ;;; in general-describe-keybindings here: 934 | ;;; Its useful to duplicate these simply as a way of documentation: 935 | (general-define-key 936 | "M-SPC" 'cycle-spacing ; If you document it, you will use it. 937 | "M-h" 'mark-paragraph ; C-h B is like your personal cheat sheet. 938 | "C-h b" 'describe-bindings ;; default binding for documentation purpose 939 | "C-x 4 c" 'clone-indirect-buffer-other-window ;; default binding 940 | ) 941 | ;;; Define bindings for specific builtin (non use-package) modes: 942 | ;; Emacs Lisp mode bindings: 943 | (general-define-key 944 | :keymaps 'emacs-lisp-mode-map 945 | "s-e" 'eval-defun ;eval top-level form 946 | "M-;" 'paredit-comment-dwim) 947 | ;; Dired mode bindings: 948 | (general-define-key 949 | :keymaps 'dired-mode-map "C-c C-q" 'dired-toggle-read-only)) 950 | #+end_src 951 | ** Which key (label =which-key=) 952 | 953 | * [[https://github.com/justbur/emacs-which-key][which-key]] 954 | 955 | #+begin_src emacs-lisp :tangle "modules/which-key/which-key.el" :mkdirp yes 956 | ;; which-key (shows keyboard shortcut completions) :: https://github.com/justbur/emacs-which-key 957 | (use-package which-key :config (which-key-mode)) 958 | #+end_src 959 | ** Org mode (label =org=) 960 | 961 | * [[https://orgmode.org/][org-mode]] 962 | 963 | #+begin_src emacs-lisp :tangle "modules/org/org.el" 964 | ;; hydra (rapid fire mnemonic keybindings) :: https://github.com/abo-abo/hydra 965 | (use-package hydra) 966 | (use-package org 967 | :after hydra 968 | :hook ((org-mode . flyspell-mode) 969 | (org-mode . unpackaged/org-export-html-with-useful-ids-mode)) 970 | :custom 971 | (org-html-validation-link nil) 972 | (org-html-use-infojs nil) 973 | (org-html-postamble 'auto) 974 | (org-export-with-author t) 975 | (org-export-with-date t) 976 | (org-export-with-creator nil) 977 | (org-export-with-email nil) 978 | (org-export-timestamp-file t) 979 | (org-export-allow-bind-keywords t) 980 | (org-directory "~/Org") 981 | :general 982 | ("s-" 'org-previous-visible-heading) 983 | ("s-" 'org-next-visible-heading) 984 | ("C-c o k" 'org-babel-remove-result) 985 | :config 986 | (setq org-startup-folded t) 987 | (defun my-org-html--translate (original-function keyword info) 988 | "Custom advice to translate the keyword 'Created' to 'Last Modified'." 989 | (if (string-equal keyword "Created") 990 | "Last Modified" 991 | (funcall original-function keyword info))) 992 | (advice-add 'org-html--translate :around #'my-org-html--translate) 993 | (org-babel-do-load-languages 994 | 'org-babel-load-languages 995 | '((python . t) (scheme . t) (shell . t) (ditaa . t))) 996 | :init 997 | (defcustom my/org-notes-directory "~/Org/notes" "My org notes directory") 998 | (defcustom my/org-notes-export-directory "~/Org/export/notes" "My org notes HTML export directory") 999 | ;; Hydra for commonly used org commands: 1000 | (defhydra 1001 | hydra-org 1002 | (global-map "C-c o" :exit t color pink :hint nil) 1003 | "Org commands:" 1004 | ("o" my/org-open-file) 1005 | ("l" org-store-link "store link") 1006 | ("i" org-insert-link "insert link") 1007 | ("a" org-agenda "agenda") 1008 | ("c" org-capture "capture") 1009 | ("m" org-info "read info manual") 1010 | ("e" org-export-dispatch "export") 1011 | ("p" org-preview-html-mode "toggle preview mode") 1012 | ("s" org-insert-source-code-block "insert source code block")) 1013 | ) 1014 | (require 'org-tempo) ; required for Structure Templates 1015 | ; See https://orgmode.org/manual/Structure-Templates.html 1016 | (use-package htmlize) ; required for colorized HTML code blocks 1017 | (use-package org-preview-html :after org) 1018 | (use-package ob-async) 1019 | (progn ; electic pairs for org-mode 1020 | (modify-syntax-entry ?/ "\"" org-mode-syntax-table) 1021 | (modify-syntax-entry ?* "\"" org-mode-syntax-table) 1022 | (modify-syntax-entry ?= "\"" org-mode-syntax-table) 1023 | (modify-syntax-entry ?+ "\"" org-mode-syntax-table) 1024 | (modify-syntax-entry ?_ "\"" org-mode-syntax-table) 1025 | (modify-syntax-entry ?~ "\"" org-mode-syntax-table)) 1026 | #+end_src 1027 | 1028 | #+begin_src emacs-lisp :tangle "~/Org/notes/.dir-locals.el" :mkdirp yes 1029 | ((org-mode 1030 | . ((org-confirm-babel-evaluate . nil) 1031 | (eval . 1032 | (add-hook 'after-save-hook 1033 | (lambda () 1034 | (when (and buffer-file-name 1035 | (string= "org" (file-name-extension buffer-file-name))) 1036 | (my/org-babel-tangle buffer-file-name))) 1037 | nil t)))))) 1038 | #+end_src 1039 | 1040 | *** Tangle Emacs config and write HTML document 1041 | 1042 | This function tangles this file (=emacs.org=) and exports an HTML page 1043 | (=emacs.html=): 1044 | 1045 | #+begin_src emacs-lisp :tangle "modules/org/org.el" :mkdirp yes 1046 | (defcustom my/org-html-theme "simple_dark" "the name of my custom org theme (CSS)") 1047 | (defun my/emacs-org-tangle () 1048 | "Tangle all code blocks in 'emacs.org' and export this document to HTML." 1049 | (let* ((org-file (expand-file-name "emacs.org" user-emacs-directory)) 1050 | (modules-dir (expand-file-name "modules" user-emacs-directory)) 1051 | (export-dir (expand-file-name my/org-notes-export-directory)) 1052 | (export-emacs-dir (expand-file-name "emacs" export-dir)) 1053 | (export-file (expand-file-name "index.html" user-emacs-directory))) 1054 | (when (file-exists-p org-file) 1055 | (with-current-buffer (find-file-noselect org-file) 1056 | (delete-directory modules-dir t) 1057 | (org-babel-tangle) 1058 | (org-export-to-file 'html export-file) 1059 | (unless (file-directory-p export-dir) 1060 | (make-directory export-dir t)) 1061 | (unless (file-directory-p export-emacs-dir) 1062 | (make-directory export-emacs-dir t)) 1063 | (my/org-create-theme-file) 1064 | (make-symbolic-link "index.html" "emacs.html" t) 1065 | (make-symbolic-link (expand-file-name "index.html" user-emacs-directory) (expand-file-name "index.html" export-emacs-dir) t) 1066 | (make-symbolic-link (expand-file-name "index.html" user-emacs-directory) (expand-file-name "emacs.html" export-emacs-dir) t) 1067 | (make-symbolic-link (expand-file-name "early-init.el" user-emacs-directory) (expand-file-name "early-init.el" export-emacs-dir) t) 1068 | (make-symbolic-link (expand-file-name "init.el" user-emacs-directory) (expand-file-name "init.el" export-emacs-dir) t) 1069 | (make-symbolic-link (expand-file-name "modules" user-emacs-directory) (expand-file-name "modules" export-emacs-dir) t) 1070 | (make-symbolic-link (expand-file-name "LICENSE.txt" user-emacs-directory) (expand-file-name "LICENSE.txt" export-emacs-dir) t) 1071 | (make-symbolic-link (expand-file-name "LICENSE_GPLv3.txt" user-emacs-directory) (expand-file-name "LICENSE_GPLv3.txt" export-emacs-dir) t) 1072 | (make-symbolic-link (expand-file-name "theme" user-emacs-directory) (expand-file-name "theme" export-dir) t) 1073 | (make-symbolic-link (expand-file-name "theme" user-emacs-directory) (expand-file-name "theme" my/org-notes-directory) t) 1074 | )))) 1075 | (with-eval-after-load 'ox-html 1076 | (defun my/org-html-src-block (orig-fun src-block contents info) 1077 | "Advice for `org-html-src-block' to add a header. 1078 | If a :tangle header is specified (and not \"no\"), it shows the tangle file. 1079 | If the block is a shell block, it prints 'Run in Bash shell:'. 1080 | Otherwise, it prints the code block's language. 1081 | ORIG-FUN is the original function; SRC-BLOCK is the source block; 1082 | INFO is the export options plist." 1083 | (let* ((parameters (org-element-property :parameters src-block)) 1084 | (header-args (org-babel-parse-header-arguments parameters)) 1085 | (tangle (cdr (assoc :tangle header-args))) 1086 | (lang (org-element-property :language src-block)) 1087 | (header (cond 1088 | ((and tangle (not (string= tangle "no"))) 1089 | (format "
:tangle %s
\n" 1090 | (org-html-encode-plain-text tangle))) 1091 | ((string= lang "shell") 1092 | "
Run this in your shell ::
\n") 1093 | ((string= lang "example") 1094 | "
Example ::
\n") 1095 | (lang 1096 | (format "
(untangled) %s
\n" 1097 | (org-html-encode-plain-text lang))) 1098 | (t ""))) 1099 | (code (funcall orig-fun src-block contents info))) 1100 | (if (not (string= header "")) 1101 | (format "
%s%s
" header code) 1102 | code))) 1103 | (advice-add 'org-html-src-block :around #'my/org-html-src-block)) 1104 | 1105 | ;; Tell Emacs to trust this code in all buffer local vars: 1106 | (add-to-list 'safe-local-variable-values 1107 | '(eval add-hook 'after-save-hook 'my/emacs-org-tangle nil t)) 1108 | (add-to-list 'safe-local-variable-values 1109 | '(org-confirm-babel-evaluate)) 1110 | #+end_src 1111 | 1112 | *** Local HTTP server for displaying exported HTML 1113 | #+begin_src emacs-lisp :tangle "modules/org/org.el" :mkdirp yes 1114 | (my/cargo-dependency "live-server") ; defers install of live-server Rust crate 1115 | (defvar my/org-html-server-host "127.0.0.1") ; Set to 0.0.0.0 to serve publicly 1116 | (defvar my/org-html-server-port "7776") 1117 | (defun my/org-html-server (&optional redirect) 1118 | "Start a local live-server for my org notes. 1119 | If the server is already running, open the URL." 1120 | (interactive) 1121 | (let* ((host my/org-html-server-host) 1122 | (port my/org-html-server-port) 1123 | (redirect (or redirect "")) 1124 | (url (format "http://%s:%s/%s" host port redirect)) 1125 | (live-server-proc (get-process "live-server"))) 1126 | (if (and live-server-proc (process-live-p live-server-proc)) 1127 | (progn 1128 | (message "live-server already running; opening %s" url) 1129 | (browse-url url)) 1130 | (let ((live-server-path (executable-find "live-server")) 1131 | (log-buffer-name "*my/org-html-server*") 1132 | (export-dir (expand-file-name my/org-notes-export-directory))) 1133 | (with-current-buffer (get-buffer-create log-buffer-name) 1134 | (if live-server-path 1135 | (progn 1136 | (message "live-server found at: %s" live-server-path) 1137 | (start-process "live-server" log-buffer-name "live-server" 1138 | "-H" host "-p" port "-o" redirect export-dir) 1139 | (message "Started live-server on %s" url)) 1140 | (message "live-server NOT found – please run: cargo install live-server"))))))) 1141 | (defun my/emacs-org-html-server () 1142 | "Start a local live-server and redirect to the emacs page" 1143 | (interactive) 1144 | (my/org-html-server "emacs")) 1145 | (defun my/org-notes-html-server () 1146 | "Start a local live-server and redirect to the current Org note file. 1147 | If the current buffer is an Org file in `my/org-notes-directory`, tangle 1148 | it and export to HTML before serving it." 1149 | (interactive) 1150 | (let ((org-file (buffer-file-name))) 1151 | (if (and org-file 1152 | (string= "org" (file-name-extension org-file)) 1153 | (string-prefix-p (expand-file-name my/org-notes-directory) (expand-file-name org-file))) 1154 | (let ((html-file (concat (file-name-sans-extension org-file) ".html"))) 1155 | (my/org-babel-tangle org-file) 1156 | (my/org-html-server (file-name-nondirectory html-file))) 1157 | (message "Current buffer is not an Org file in %s" my/org-notes-directory)))) 1158 | #+end_src 1159 | 1160 | |--------------------------------| 1161 | | Start the html server | 1162 | |--------------------------------| 1163 | | =M-x my/org-html-server= | 1164 | | =M-x my/emacs-org-html-server= | 1165 | 1166 | *** Use org headings as HTML anchors 1167 | 1168 | [[https://github.com/alphapapa/unpackaged.el/tree/master?tab=readme-ov-file#export-to-html-with-useful-anchors][unpackaged.el: Export to HTML with useful anchors]] 1169 | 1170 | #+begin_src emacs-lisp :tangle "modules/org/org-mode-unpackaged.el" 1171 | ;; This is a modified portion of unpackaged.el 1172 | ;; 1173 | ;; Copyright (C) 2018 Adam Porter 1174 | ;; URL: https://github.com/alphapapa/unpackaged.el 1175 | ;; 1176 | ;;; License: 1177 | ;; This program is free software; you can redistribute it and/or modify 1178 | ;; it under the terms of the GNU General Public License as published by 1179 | ;; the Free Software Foundation, either version 3 of the License, or 1180 | ;; (at your option) any later version. 1181 | ;; 1182 | ;; This program is distributed in the hope that it will be useful, 1183 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 1184 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1185 | ;; GNU General Public License for more details. 1186 | ;; 1187 | ;; You should have received a copy of the GNU General Public License 1188 | ;; along with this program. If not, see . 1189 | 1190 | (require 'cl-lib) 1191 | (define-minor-mode unpackaged/org-export-html-with-useful-ids-mode 1192 | "Attempt to export Org as HTML with useful link IDs. 1193 | Instead of random IDs like \"#orga1b2c3\", use heading titles, 1194 | made unique when necessary." 1195 | :global t 1196 | (if unpackaged/org-export-html-with-useful-ids-mode 1197 | (advice-add #'org-export-get-reference :override 1198 | #'unpackaged/org-export-get-reference) 1199 | (advice-remove #'org-export-get-reference 1200 | #'unpackaged/org-export-get-reference))) 1201 | (defun unpackaged/org-export-get-reference (datum info) 1202 | "Like `org-export-get-reference', 1203 | except uses heading titles instead of random numbers." 1204 | (let ((cache (plist-get info :internal-references))) 1205 | (or (car (rassq datum cache)) 1206 | (let* ((crossrefs (plist-get info :crossrefs)) 1207 | (cells (org-export-search-cells datum)) 1208 | ;; Preserve any pre-existing association between 1209 | ;; a search cell and a reference. 1210 | (new (or (cl-some 1211 | (lambda (cell) 1212 | (let ((stored (cdr (assoc cell crossrefs)))) 1213 | (when stored 1214 | (let ((old (org-export-format-reference stored))) 1215 | (and (not (assoc old cache)) stored))))) 1216 | cells) 1217 | (when (org-element-property :raw-value datum) 1218 | ;; Heading with a title 1219 | (unpackaged/org-export-new-title-reference datum cache)) 1220 | ;; Generate new reference 1221 | (org-export-format-reference 1222 | (org-export-new-reference cache)))) 1223 | (reference-string (replace-regexp-in-string "%20" "_" new))) 1224 | ;; Cache contains both data already associated to 1225 | ;; a reference and in-use internal references, so as to make 1226 | ;; unique references. 1227 | (dolist (cell cells) (push (cons cell new) cache)) 1228 | ;; Retain a direct association between reference string and DATUM. 1229 | (push (cons reference-string datum) cache) 1230 | (plist-put info :internal-references cache) 1231 | reference-string)))) 1232 | (defun unpackaged/org-export-new-title-reference (datum cache) 1233 | "Return new reference for DATUM that is unique in CACHE." 1234 | (cl-macrolet ((inc-suffixf (place) 1235 | `(progn 1236 | (string-match (rx bos 1237 | (minimal-match (group (1+ anything))) 1238 | (optional "--" (group (1+ digit))) 1239 | eos) 1240 | ,place) 1241 | ;; HACK: `s1' instead of a gensym. 1242 | (-let* (((s1 suffix) (list (match-string 1 ,place) 1243 | (match-string 2 ,place))) 1244 | (suffix (if suffix 1245 | (string-to-number suffix) 1246 | 0))) 1247 | (setf ,place (format "%s--%s" s1 (cl-incf suffix))))))) 1248 | (let* ((title (org-element-property :raw-value datum)) 1249 | (ref (url-hexify-string (substring-no-properties title))) 1250 | (parent (org-element-property :parent datum))) 1251 | (while (cl-some (lambda (it) (equal ref (car it))) cache) 1252 | ;; Title not unique: make it so. 1253 | (if parent 1254 | ;; Append ancestor title. 1255 | (setf title (concat (org-element-property :raw-value parent) 1256 | "--" title) 1257 | ref (url-hexify-string (substring-no-properties title)) 1258 | parent (org-element-property :parent parent)) 1259 | ;; No more ancestors: add and increment a number. 1260 | (inc-suffixf ref))) 1261 | ref))) 1262 | #+end_src 1263 | 1264 | *** Template for new org files 1265 | #+begin_src emacs-lisp :tangle "modules/org/org.el" :mkdirp yes 1266 | (defcustom my/org-template 1267 | (concat "#+TITLE: {{title}}\n" 1268 | "#+PROPERTY: header-args :exports both :results both :eval never-export\n" 1269 | "#+OPTIONS: noweb:t\n") 1270 | "My default Org template.") 1271 | 1272 | (defun my/org-create-theme-file () 1273 | "Create the theme file in the 'theme' directory under `user-emacs-directory`. 1274 | This file wraps the contents of the theme CSS (also in the theme directory) 1275 | with HTML \n") 1291 | theme-file))) 1292 | 1293 | (defun my/org-open-file () 1294 | "Open a new Org file with the default notes template and include the theme file. 1295 | This function does the following: 1296 | 1. Opens a new Org file in `org-directory/notes` and inserts the template, 1297 | replacing placeholders like {{title}}, {{date}}, etc. 1298 | 2. If the directory `org-directory/notes` does not exist, it is created. 1299 | 3. It creates (or updates) the theme file via `my/org-create-theme-file`, which is 1300 | stored in `user-emacs-directory/theme/{{theme}}.theme`. 1301 | 4. The Org file then includes a line: \"#+SETUPFILE: {{theme}}.theme\" so that 1302 | when you export, Org loads the theme file." 1303 | (interactive) 1304 | (let* ((formatted-date (format-time-string "%Y-%m-%d")) 1305 | (user-title (read-string "Title for new note: ")) 1306 | (safe-title (replace-regexp-in-string " " "-" (downcase user-title))) 1307 | ;; Define the notes directory and ensure it exists. 1308 | (notes-dir (file-name-as-directory (concat org-directory "/notes"))) 1309 | (_ (unless (file-directory-p notes-dir) 1310 | (make-directory notes-dir t))) 1311 | (filename (format "%s/%s-%s.org" 1312 | notes-dir 1313 | (format-time-string "%Y-%m-%d-%H-%M-%S") 1314 | safe-title)) 1315 | (section (read-string "Section: " formatted-date)) 1316 | (title-section (mapconcat #'capitalize (split-string section " ") " "))) 1317 | (unless (file-directory-p my/org-notes-directory) 1318 | (make-directory my/org-notes-directory t)) 1319 | (find-file filename) 1320 | (when (zerop (buffer-size)) 1321 | ;; Insert the Org template with placeholders replaced. 1322 | (insert 1323 | (replace-regexp-in-string 1324 | "{{title}}" 1325 | user-title 1326 | (replace-regexp-in-string 1327 | "{{date}}" 1328 | formatted-date 1329 | (replace-regexp-in-string 1330 | "{{section}}" 1331 | section 1332 | (replace-regexp-in-string 1333 | "{{safe-title}}" 1334 | safe-title 1335 | (replace-regexp-in-string 1336 | "{{title-section}}" 1337 | title-section 1338 | my/org-template)))))) 1339 | ;; Create the theme file and insert the setup line. 1340 | (let ((theme-file (my/org-create-theme-file))) 1341 | (insert (format "#+SETUPFILE: theme/%s\n\n" 1342 | (file-name-nondirectory theme-file))))))) 1343 | 1344 | (defun my/org-babel-tangle (org-file) 1345 | "Tangle and export an Org file to HTML." 1346 | (when (file-exists-p org-file) 1347 | (with-current-buffer (find-file-noselect org-file) 1348 | (org-babel-tangle) 1349 | (my/org-create-theme-file) 1350 | (org-export-to-file 'html 1351 | (expand-file-name (org-export-output-file-name ".html" nil) 1352 | my/org-notes-export-directory))))) 1353 | #+end_src 1354 | *** Org-babel evaluation 1355 | #+begin_src emacs-lisp :tangle "modules/org/org.el" :mkdirp yes 1356 | (defun my/save-buffer-after-code-execution (orig-fun &rest args) 1357 | "Execute ORIG-FUN with ARGS and save the buffer afterward. 1358 | If the code block is executed asynchronously (i.e. returns a process), 1359 | attach a sentinel so that `save-buffer` is called when the process finishes. 1360 | Otherwise, call `save-buffer` immediately." 1361 | (let ((result (apply orig-fun args))) 1362 | (if (processp result) 1363 | (set-process-sentinel 1364 | result 1365 | (lambda (_proc event) 1366 | ;; Adjust this if your process returns a different finished event. 1367 | (when (string-match-p "finished" event) 1368 | (save-buffer)))) 1369 | (save-buffer)) 1370 | result)) 1371 | (advice-add 'org-babel-execute-src-block :around #'my/save-buffer-after-code-execution) 1372 | (advice-add 'rustic-babel-run-update-result-block :around #'my/save-buffer-after-code-execution) 1373 | #+end_src 1374 | ** Ace window (label =ace-window=) 1375 | 1376 | * [[https://github.com/abo-abo/ace-window][ace-window]] 1377 | 1378 | #+begin_src emacs-lisp :tangle "modules/ace-window/ace-window.el" :mkdirp yes 1379 | (use-package ace-window 1380 | :general ("C-x o" 'ace-window)) 1381 | #+end_src 1382 | ** Completion (label =completion=) 1383 | 1384 | * [[https://github.com/minad/vertico][vertico]] 1385 | * [[https://github.com/oantolin/orderless][orderless]] 1386 | * [[https://github.com/minad/marginalia][marginalia]] 1387 | * [[https://company-mode.github.io/][company-mode]] 1388 | * [[https://github.com/minad/consult][consult]] 1389 | 1390 | #+begin_src emacs-lisp :tangle "modules/completion/completion.el" :mkdirp yes 1391 | ;; Allow minibuffers to stack: 1392 | (setq-default enable-recursive-minibuffers t) 1393 | ;; Filter command completions to only include commands 1394 | ;; applicable to the current major mode: 1395 | (setq-default read-extended-command-predicate 1396 | #'command-completion-default-include-p) 1397 | ;; Add custom prompt when asking for multiple values as (comma) separated list: 1398 | (advice-add #'completing-read-multiple :filter-args 1399 | (lambda (args) 1400 | (cons (format "[CRM%s] %s" 1401 | (replace-regexp-in-string 1402 | "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" 1403 | crm-separator) 1404 | (car args)) 1405 | (cdr args)))) 1406 | ;; Do not allow the cursor in the minibuffer prompt 1407 | (setq minibuffer-prompt-properties 1408 | '(read-only t cursor-intangible t face minibuffer-prompt)) 1409 | (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) 1410 | (use-package 1411 | consult 1412 | :general ("C-x b" 'consult-buffer) 1413 | (setq consult-buffer-sources 1414 | '(consult--source-buffers 1415 | consult--source-recent-file 1416 | consult--source-project-buffer))) 1417 | 1418 | (use-package vertico 1419 | :custom 1420 | (vertico-scroll-margin 2) 1421 | (vertico-count 10) 1422 | (vertico-resize 'grow-only) 1423 | (vertico-cycle nil) 1424 | :init 1425 | ;;(keymap-set vertico-map "?" #'minibuffer-completion-help) 1426 | ;;(keymap-set vertico-map "M-TAB" #'vertico-insert) 1427 | ;;(keymap-set vertico-map "TAB" #'minibuffer-complete) 1428 | (vertico-mode)) 1429 | 1430 | (use-package orderless 1431 | :custom 1432 | ;; Configure a custom style dispatcher (see the Consult wiki) 1433 | ;; (orderless-style-dispatchers 1434 | ;; '(+orderless-consult-dispatch orderless-affix-dispatch)) 1435 | ;; (orderless-component-separator #'orderless-escapable-split-on-space) 1436 | (completion-styles '(orderless basic)) 1437 | (completion-category-defaults nil) 1438 | (completion-category-overrides '((file (styles partial-completion))))) 1439 | 1440 | (use-package marginalia 1441 | :hook 1442 | ((marginalia-mode . all-the-icons-completion-marginalia-setup)) 1443 | :bind (:map minibuffer-local-map 1444 | ("M-A" . marginalia-cycle)) 1445 | :init 1446 | (marginalia-mode)) 1447 | 1448 | (use-package nerd-icons-completion 1449 | :init 1450 | (nerd-icons-completion-mode)) 1451 | 1452 | (use-package company) 1453 | #+end_src 1454 | ** Vterm (label =vterm=) 1455 | 1456 | #+begin_src emacs-lisp :tangle "modules/vterm/vterm.el" :mkdirp yes 1457 | ;; vterm (terminal emulator) :: 1458 | ;; https://github.com/akermu/emacs-libvterm 1459 | ;; Configure BASH to work with vterm: 1460 | ;; https://github.com/akermu/emacs-libvterm#vterm-clear-scrollback 1461 | (use-package 1462 | vterm 1463 | :custom (vterm-always-compile-module t) 1464 | :general ("C-c t" 'my/vterm-toggle) 1465 | :config (define-key vterm-mode-map (kbd "") nil) 1466 | :hook ((vterm-mode . (lambda () (setq-local show-trailing-whitespace nil)))) 1467 | :init 1468 | ;; shell-pop for vterm :: https://github.com/jixiuf/vterm-toggle 1469 | (use-package vterm-toggle) 1470 | (defun my/vterm-toggle (&optional args) 1471 | "Customized vterm-toggle wrapper- this fixes the universal 1472 | argument (C-u) to always create a new terminal" 1473 | (interactive "P") 1474 | (if (not 1475 | (or (derived-mode-p 'vterm-mode) 1476 | (and (vterm-toggle--get-window) 1477 | vterm-toggle-hide-method))) 1478 | (if (equal current-prefix-arg '(4)) 1479 | (vterm-toggle--new args) 1480 | (vterm-toggle args)) 1481 | (vterm-toggle args)))) 1482 | #+end_src 1483 | 1484 | ** Markdown mode (label =markdown=) 1485 | 1486 | #+begin_src emacs-lisp :tangle "modules/markdown/markdown.el" :mkdirp yes 1487 | (use-package markdown-mode) 1488 | #+end_src 1489 | 1490 | ** SSH agent (label =ssh-agent=) 1491 | 1492 | #+begin_src emacs-lisp :tangle "modules/ssh-agent/ssh-agent.el" :mkdirp yes 1493 | ;; Load SSH / GPG keys from keychain agent 1494 | (use-package 1495 | keychain-environment 1496 | :straight 1497 | (keychain-environment 1498 | :type git 1499 | :files (:defaults "keychain-environment") 1500 | :host github 1501 | :repo "tarsius/keychain-environment") 1502 | :init (keychain-refresh-environment)) 1503 | #+end_src 1504 | 1505 | ** Magit (label =magit=) 1506 | 1507 | #+begin_src emacs-lisp :tangle "modules/magit/magit.el" :mkdirp yes 1508 | ;; Magit (git version control system) :: https://magit.vc/ 1509 | (use-package 1510 | magit 1511 | :general ("C-c g" 'magit-status) 1512 | :config 1513 | ;; open magit in a full frame always: 1514 | (setq magit-display-buffer-function 1515 | #'magit-display-buffer-fullframe-status-v1)) 1516 | #+end_src 1517 | ** Scale text uniformly in all buffers (label =text-scale=) 1518 | #+begin_src emacs-lisp :tangle "modules/text-scale/text-scale.el" :mkdirp yes 1519 | (defun my/default-text-scale-reset nil 1520 | (setq default-text-scale--complement 0) 1521 | (set-face-attribute 'default 1522 | nil 1523 | :height my/default-text-height) 1524 | (message "Text height reset: %d" my/default-text-height) 1525 | ) 1526 | ;; Scale text sizes in all buffers :: https://github.com/purcell/default-text-scale 1527 | (use-package 1528 | default-text-scale 1529 | :general 1530 | ("C-=" 1531 | 'default-text-scale-increase 1532 | "C--" 1533 | (lambda () 1534 | "Reset text scale if C-u is used, otherwise decrease it." 1535 | (interactive) 1536 | (let ((prefix current-prefix-arg)) 1537 | ;; Intercept and clear the prefix argument before calling the function 1538 | (setq current-prefix-arg nil) 1539 | (if prefix 1540 | (my/default-text-scale-reset) 1541 | (default-text-scale-decrease))))) 1542 | :init (setq default-text-scale-amount 5)) 1543 | #+end_src 1544 | ** Justfile mode (label =just=) 1545 | 1546 | #+begin_src emacs-lisp :tangle "modules/just/just.el" :mkdirp yes 1547 | ;; just-mode 1548 | (use-package just-mode) 1549 | #+end_src 1550 | 1551 | ** Latin words dictionary and word of the day (label =latin-words=) 1552 | 1553 | This package requires the system dependency [[https://jqlang.github.io/jq/download/][jq]]. 1554 | 1555 | #+begin_src emacs-lisp :tangle "modules/latin-words/latin-words.el" :mkdirp yes 1556 | (use-package 1557 | latin-words 1558 | :straight 1559 | (latin-words :type git :host github :repo "enigmacurry/latin-words") 1560 | :custom 1561 | (latin-words-directory 1562 | (expand-file-name "straight/repos/latin-words/data" user-emacs-directory))) 1563 | #+end_src 1564 | ** Dashboard (label =dashboard=) 1565 | #+begin_src emacs-lisp :tangle "modules/dashboard/dashboard.el" :mkdirp yes 1566 | (use-package 1567 | dashboard 1568 | :init 1569 | (defun my-dashboard-insert-vocabulary (list-size) 1570 | (when (fboundp 'latin-word-of-the-day) 1571 | (dashboard-insert-heading "Word of the day:" nil) 1572 | (insert "\n") 1573 | (let* ((char-limit 100000) 1574 | (word (latin-word-of-the-day)) 1575 | (description (latin-word-get-description word))) 1576 | (insert 1577 | (substring description 1578 | 0 1579 | (min char-limit (length description))))))) 1580 | (dashboard-setup-startup-hook) 1581 | :hook 1582 | ((dashboard-mode . (lambda () (setq-local show-trailing-whitespace nil)))) 1583 | :custom 1584 | (dashboard-center-content t) 1585 | (dashboard-set-heading-icons nil) 1586 | (dashboard-set-file-icons nil) 1587 | (dashboard-icon-type nil) 1588 | (dashboard-footer-messages (list " ")) 1589 | (dashboard-items '((recents . 5) (bookmarks . 5) (vocabulary))) 1590 | (dashboard-startup-banner (+ 1 (random 3))) 1591 | (dashboard-item-generators 1592 | '((vocabulary . my-dashboard-insert-vocabulary) 1593 | (recents . dashboard-insert-recents) 1594 | (bookmarks . dashboard-insert-bookmarks)))) 1595 | #+end_src 1596 | ** GPTel (label =gptel=) 1597 | #+begin_src emacs-lisp :tangle "modules/gptel/gptel.el" :mkdirp yes 1598 | (use-package 1599 | gptel 1600 | :general 1601 | ("C-c C-g" 'gptel-menu) 1602 | (:keymaps 'gptel-mode-map "C-c C-c" 'gptel-send) 1603 | :config (add-hook 'gptel-post-response-functions 'gptel-end-of-response) 1604 | ;(add-hook 'gptel-post-stream-hook 'gptel-auto-scroll) 1605 | (setq gptel-org-branching-context t) 1606 | :init 1607 | ;; LM-studio offers an OpenAI compatible API 1608 | (setq 1609 | gptel-model 'test 1610 | gptel-backend 1611 | (gptel-make-openai 1612 | "lm-studio" 1613 | :stream t 1614 | :protocol "http" 1615 | :host "localhost:1234" 1616 | :models '(test)))) 1617 | #+end_src 1618 | ** LSP (label =lsp=) 1619 | #+begin_src emacs-lisp :tangle "modules/lsp/lsp.el" :mkdirp yes 1620 | ;; LSP mode :: https://emacs-lsp.github.io/lsp-mode/ 1621 | (use-package 1622 | lsp-mode 1623 | :init 1624 | ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l") 1625 | (setq lsp-keymap-prefix "C-c l") 1626 | (setq lsp-modeline-diagnostics-scope :workspace) 1627 | ;;; extra verbose logging of lsp json messages: 1628 | ;;(setq lsp-log-io t) 1629 | :hook 1630 | ((web-mode . lsp) 1631 | ;(lsp-mode . lsp-enable-which-key-integration) 1632 | (python-mode . lsp-deferred)) 1633 | :commands lsp 1634 | :config) 1635 | (use-package lsp-ui :commands lsp-ui-mode) 1636 | (use-package lsp-ivy :commands lsp-ivy-workspace-symbol) 1637 | (use-package lsp-treemacs :commands lsp-treemacs-errors-list) 1638 | (use-package flycheck) 1639 | 1640 | ;; LSP debuggers 1641 | (use-package dap-mode) 1642 | ;; (use-package dap-LANGUAGE) to load the dap adapter for your language 1643 | #+end_src 1644 | ** Avy (label =avy=) 1645 | 1646 | * [[https://github.com/abo-abo/avy][avy]] lets you jump to any word you can see in your Emacs frame. 1647 | 1648 | #+begin_src emacs-lisp :tangle "modules/avy/avy.el" :mkdirp yes 1649 | ;; Avy (like ace-jump) :: https://github.com/abo-abo/avy 1650 | (use-package 1651 | avy 1652 | :general 1653 | ;;; These are if you want to use avy by itself, 1654 | ;;; Otherwise these keys will be defined by treesit-jump instead. 1655 | ("s-s" 'avy-goto-word-1) 1656 | ("C-c s" 'avy-goto-char) 1657 | ("C-c S" 'avy-goto-word-1)) 1658 | #+end_src 1659 | 1660 | ** Treesit (label =treesit=) 1661 | 1662 | Treesit is an Emacs builtin language syntax parser. 1663 | 1664 | * [[https://www.masteringemacs.org/article/how-to-get-started-tree-sitter][Mastering Emacs: How to Get Started with Tree-Sitter]] 1665 | 1666 | There are several third party modules to configure and enhance it: 1667 | 1668 | * [[https://github.com/renzmann/treesit-auto][treesit-auto]] 1669 | * [[https://github.com/dmille56/treesit-jump][treesit-jump]] 1670 | 1671 | #+begin_src emacs-lisp :tangle "modules/treesit/treesit.el" :mkdirp yes 1672 | (use-package treesit-auto 1673 | :custom 1674 | (treesit-auto-langs '(awk bash bibtex blueprint c c-sharp 1675 | clojure cmake commonlisp cpp css dart dockerfile elixir glsl go 1676 | gomod heex html janet java javascript json julia kotlin latex 1677 | lua magik make markdown nix nu org perl proto r ruby 1678 | scala sql surface toml tsx typescript typst verilog vhdl vue 1679 | wast wat wgsl yaml)) 1680 | (treesit-auto-install 'prompt) 1681 | :config 1682 | (treesit-auto-add-to-auto-mode-alist 'all) 1683 | (global-treesit-auto-mode)) 1684 | 1685 | (use-package treesit-jump 1686 | :straight (:host github :repo "dmille56/treesit-jump" :files ("*.el" "treesit-queries")) 1687 | :config 1688 | ;; Optional: add some queries to filter out of results (since they can be too cluttered sometimes) 1689 | ;;(setq treesit-jump-queries-filter-list '("inner" "test" "param")) 1690 | #+end_src 1691 | 1692 | ** S3-publish (label =s3-publish=) 1693 | 1694 | [[https://github.com/EnigmaCurry/s3-publish.el][s3-publish.el]] is a quick/temporary way to publish Emacs buffers, 1695 | regions, and files to S3 storage and the web. 1696 | 1697 | #+begin_src emacs-lisp :tangle "modules/s3-publish/s3-publish.el" :mkdirp yes 1698 | (use-package 1699 | s3-publish 1700 | :straight 1701 | (s3-publish 1702 | :type 1703 | git 1704 | :repo 1705 | "https://github.com/EnigmaCurry/s3-publish.el.git") 1706 | :init 1707 | (require 's3-publish) 1708 | :general 1709 | ("C-c p" 's3-publish)) 1710 | #+end_src 1711 | ** Python (label =python=) 1712 | 1713 | * [[https://github.com/astral-sh/uv][uv]] - The uv package manager is installed from source when 1714 | requested. Please be patient while it builds during its initial 1715 | load. 1716 | 1717 | #+begin_src emacs-lisp :tangle "modules/python/python.el" :mkdirp yes 1718 | (my/add-exec-path "~/.local/bin") 1719 | (defun my/python-install-uv-package-manager () 1720 | "Install uv package manager via cargo" 1721 | (my/cargo-install '(("uv" . "https://github.com/astral-sh/uv")))) 1722 | (defun my/python-uv-execute (command) 1723 | (my/python-install-uv-package-manager) 1724 | (my/shell-execute command)) 1725 | (defun my/python-install-ruff () 1726 | (unless (executable-find "ruff") 1727 | (my/python-uv-execute "uv tool install ruff@latest"))) 1728 | (use-package 1729 | python-mode 1730 | :general ("s-a" 'lsp-execute-code-action) 1731 | :init 1732 | (my/python-install-ruff) 1733 | (setq auto-mode-alist 1734 | (rassq-delete-all 'python-mode auto-mode-alist)) 1735 | (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) 1736 | (autoload 'python-mode "python-mode" "Python mode." t) 1737 | :hook 1738 | (python-mode . pyvenv-mode) 1739 | (python-mode . flycheck-mode) 1740 | (python-mode . company-mode) 1741 | (python-mode . python-black-on-save-mode) 1742 | :custom (python-shell-interpreter "python3") 1743 | :config 1744 | ;; Activate python virtualenv BEFORE opening a python buffer and/or starting pyright server: 1745 | ;; M-x pyvenv-activate (~/.virtualenvs/XXX) 1746 | (use-package 1747 | pyvenv 1748 | :init (setenv "WORKON_HOME" "~/.virtualenvs/") 1749 | :config 1750 | ;; (pyvenv-mode t) 1751 | ;; Set correct Python interpreter 1752 | (setq pyvenv-post-activate-hooks 1753 | (list 1754 | (lambda () 1755 | (setq python-shell-interpreter 1756 | (concat pyvenv-virtual-env "bin/python"))))) 1757 | (setq pyvenv-post-deactivate-hooks 1758 | (list (lambda () (setq python-shell-interpreter "python3"))))) 1759 | ;; Black (Python code formatter) :: https://github.com/wbolster/emacs-python-black 1760 | ;; Note: this depends on black being installed in the project virtualenv as a dev dependency 1761 | (use-package python-black :demand t :after python) 1762 | ;; Python dev dependencies need to be installed in your project's virtualenv: 1763 | ;; ruff 1764 | ;; ruff-lsp 1765 | ;; black 1766 | ;;; Add the following to a .dir-locals.el to activate virtualenv automatically: 1767 | ;; ((python-mode . ((eval . (let ((project-root (locate-dominating-file 1768 | ;; (or (buffer-file-name) default-directory) 1769 | ;; ".dir-locals.el"))) 1770 | ;; (pyvenv-activate (expand-file-name "virtualenv" project-root))))))) 1771 | ) 1772 | (use-package jinja2-mode) 1773 | #+end_src 1774 | ** Rust (label =rust=) 1775 | #+begin_src emacs-lisp :tangle "modules/rust/rust.el" :mkdirp yes 1776 | ;; Rust 1777 | ;; must manually install cargo-watch, wasm-pack, cargo-generate 1778 | (my/cargo-dependency "cargo-watch") 1779 | (my/cargo-dependency "wasm-pack") 1780 | (my/cargo-dependency "cargo-generate") 1781 | (use-package 1782 | rustic 1783 | :mode ("\\.rs\\'" . rustic-mode) 1784 | ;; :hook (rustic-mode . yas-minor-mode) 1785 | :init 1786 | (setq rustic-format-on-save t) 1787 | (setq rustic-rustfmt-args "--edition 2021") 1788 | (add-to-list 'exec-path "~/.cargo/bin") 1789 | ;(defalias 'org-babel-execute:rust 'org-babel-execute:rustic) 1790 | ;(describe-function 'org-babel-execute:rust) 1791 | (add-hook 1792 | 'rustic-mode-hook 1793 | (lambda () 1794 | (define-key 1795 | rustic-mode-map 1796 | (kbd "C-c M-.") 1797 | 'lsp-rust-analyzer-open-external-docs)))) 1798 | #+end_src 1799 | 1800 | ** SQL (label =sql=) 1801 | 1802 | * [[https://github.com/purcell/sqlformat][sqlformat.el]] 1803 | * [[https://github.com/darold/pgFormatter][pgformatter]] 1804 | 1805 | #+begin_src emacs-lisp :tangle "modules/sql/sql.el" :mkdirp yes 1806 | ;; https://github.com/purcell/sqlformat 1807 | ;; https://github.com/darold/pgFormatter 1808 | (use-package 1809 | sqlformat 1810 | :config 1811 | (general-define-key 1812 | :keymaps 'sql-mode-map 1813 | "C-c f" 'sqlformat) 1814 | :init 1815 | (setq sqlformat-command 'pgformatter) 1816 | (setq sqlformat-args '("-f1" "-u1")) 1817 | (add-hook 'sql-mode-hook 'sqlformat-on-save-mode) 1818 | ) 1819 | #+end_src 1820 | 1821 | pgformatter, if its not packaged by your OS, can be installed via 1822 | podman (script must be named =pg_format=): 1823 | 1824 | #+begin_src shell 1825 | podman build -t pgformatter https://github.com/darold/pgFormatter.git 1826 | echo -e '#!/bin/bash\npodman run --rm -a stdin -a stdout -i localhost/pgformatter $@' > /tmp/pg_format 1827 | sudo install /tmp/pg_format /usr/local/bin/pg_format 1828 | #+end_src 1829 | 1830 | ** Svelte (label =svelte=) 1831 | 1832 | * Install the =typescript= package from system package manager. 1833 | * Install prettier globally: =sudo npm install -g prettier 1834 | prettier-plugin-svelte=. 1835 | * In your Svelte project, you must also install: =npm install 1836 | --save-dev prettier prettier-plugin-svelte=. 1837 | * In your Svelte project run =npm install= once more to be sure it grabbed everything. 1838 | 1839 | #+begin_src emacs-lisp :tangle "modules/svelte/svelte.el" :mkdirp yes 1840 | (use-package svelte-mode 1841 | :straight t 1842 | :mode ("\\.svelte\\'" . svelte-mode) 1843 | :init 1844 | (use-package lsp-mode 1845 | :straight t) 1846 | (use-package apheleia 1847 | :straight t) 1848 | :hook ((svelte-mode . lsp) 1849 | (svelte-mode . apheleia-mode)) 1850 | :config 1851 | (setq lsp-enable-snippet t) 1852 | 1853 | ;; Configure Apheleia to format Svelte files using Prettier v3. 1854 | ;; This command passes the current file path and forces the "svelte" parser. 1855 | (setf (alist-get 'svelte-mode apheleia-formatters) 1856 | '("prettier" "--stdin-filepath" filepath "--parser" "svelte")) 1857 | (setf (alist-get 'svelte-mode apheleia-mode-alist) 'svelte-mode) 1858 | 1859 | ;;(apheleia-global-mode +1) 1860 | ) 1861 | #+end_src 1862 | 1863 | * Load modules 1864 | 1865 | The code-blocks in this file are tangled to separate categorized files 1866 | under the =modules= sub-directory. These are loaded on a per-machine 1867 | basis based on =my/machine-has-label=: 1868 | 1869 | ** Prioritize and load requested modules 1870 | 1871 | 1872 | Here is the list of prioritized modules that must be loaded first (if 1873 | enabled): 1874 | 1875 | #+begin_src emacs-lisp :results value replace :exports results 1876 | (mapconcat (lambda (x) (format "- %s" x)) my/module-priority-list "\n") 1877 | #+end_src 1878 | 1879 | #+begin_src emacs-lisp :tangle "init.el" 1880 | (defvar my/modules-dir (expand-file-name "modules/" user-emacs-directory)) 1881 | (defvar my/module-priority-list '("general" "fonts") 1882 | "List of prioritized modules to install first.") 1883 | (defun my/load-modules (requested-modules) 1884 | "Load user-requested modules in a priority order. 1885 | REQUESTED-MODULES is a list of module names to load." 1886 | ;; Find and load all single file modules and load them regardless of any config 1887 | ;; (these onesshouldn't have any extra dependencies) 1888 | (when (file-directory-p my/modules-dir) 1889 | (let ((files (directory-files my/modules-dir t "\\.el\\'"))) 1890 | (dolist (file (sort files #'string<)) 1891 | (message "Loading module: %s" file) 1892 | (condition-case err 1893 | (load file nil 'nomessage) 1894 | (error (message "Error loading %s: %s" file err)))))) 1895 | ;; Prioritize and install the requested third party / optional modules: 1896 | (let ((prioritized-modules 1897 | (seq-filter (lambda (mod) (member mod my/module-priority-list)) 1898 | requested-modules)) 1899 | (remaining-modules 1900 | (seq-remove (lambda (mod) (member mod my/module-priority-list)) 1901 | requested-modules))) 1902 | ;; Sort prioritized modules based on `my/module-priority-list` 1903 | (setq prioritized-modules 1904 | (sort prioritized-modules 1905 | (lambda (a b) 1906 | (< (or (cl-position a my/module-priority-list) 1907 | most-positive-fixnum) 1908 | (or (cl-position b my/module-priority-list) 1909 | most-positive-fixnum))))) 1910 | ;; Combine prioritized and remaining modules 1911 | (let ((ordered-modules (append prioritized-modules 1912 | remaining-modules))) 1913 | (dolist (mod ordered-modules) 1914 | (let ((mod-path (expand-file-name mod my/modules-dir))) 1915 | (if (file-directory-p mod-path) 1916 | (progn 1917 | (message "Loading module: %s" mod) 1918 | (let ((files (directory-files mod-path t "\\.el\\'"))) 1919 | (dolist (file (sort files #'string<)) 1920 | (condition-case err 1921 | (load file nil 'nomessage) 1922 | (error (message "Error loading %s: %s" file err)))))) 1923 | (message "Skipping module: %s (not found)" mod))))))) 1924 | 1925 | ;; load the modules configured for this macchine 1926 | (my/load-modules my/machine-labels) 1927 | #+end_src 1928 | 1929 | ** Install rust helper programs declared by module 1930 | :PROPERTIES: 1931 | :CUSTOM_ID: cargo-install-my-cargo-dependencies 1932 | :END: 1933 | 1934 | #+begin_src emacs-lisp :tangle "init.el" 1935 | ;; Install rust dependencies that were declared by modules 1936 | (when my/cargo-dependencies 1937 | (my/cargo-install my/cargo-dependencies)) 1938 | #+end_src 1939 | * Local Variables :noexport: 1940 | 1941 | The local variables section needs to be at the very bottom of this 1942 | file. 1943 | 1944 | # Local Variables: 1945 | # coding: utf-8 1946 | # org-confirm-babel-evaluate: nil 1947 | # eval: (add-hook 'after-save-hook 'my/emacs-org-tangle nil t) 1948 | # End: 1949 | -------------------------------------------------------------------------------- /init.el: -------------------------------------------------------------------------------- 1 | ;; core libraries 2 | (require 'cl-lib) 3 | 4 | ;; Nice defaults 5 | (setq-default confirm-kill-emacs #'yes-or-no-p) 6 | (setq-default vc-follow-symlinks t) 7 | (setq-default indicate-empty-lines t) 8 | (setq-default indicate-buffer-boundaries 'left) 9 | (setq-default sentence-end-double-space nil) 10 | (setq-default indent-tabs-mode nil) 11 | (setq-default tab-width 4) 12 | (setq-default visible-bell t) 13 | (setq-default dired-listing-switches "-al --group-directories-first") 14 | (setq-default tramp-default-method "ssh") 15 | (setq-default native-comp-deferred-compilation-deny-list nil) 16 | (setq-default browse-url-browser-function 'browse-url-firefox) 17 | (setq-default require-final-newline t) 18 | (put 'narrow-to-region 'disabled nil) 19 | (put 'downcase-region 'disabled nil) 20 | (put 'upcase-region 'disabled nil) 21 | 22 | ;; Backups and auto-save 23 | ;; Reference: https://www.emacswiki.org/emacs/BackupDirectory 24 | ;; Reference: https://www.emacswiki.org/emacs/ForceBackups 25 | (setq backup-by-copying t) 26 | (setq backup-directory-alist 27 | `(("." . ,(expand-file-name "backup" user-emacs-directory)))) 28 | (setq delete-old-versions t) 29 | (setq kept-new-versions 6) 30 | (setq kept-old-versions 2) 31 | (setq version-control t) 32 | (setq vc-make-backup-files t) 33 | (add-hook 'before-save-hook 34 | (lambda () (setq buffer-backed-up nil))) 35 | ;; autosaves go in a separate directory 36 | (let ((auto-save-dir (expand-file-name "auto-save" user-emacs-directory))) 37 | (make-directory auto-save-dir t) 38 | (setq auto-save-file-name-transforms 39 | `((".*" ,auto-save-dir t)))) 40 | 41 | ;; Store customizations in custom.el 42 | (setq custom-file (locate-user-emacs-file "custom.el")) 43 | (when (file-exists-p custom-file) 44 | (load custom-file)) 45 | ;; Store all customizations under my/custom-settings group 46 | (defgroup my/custom-settings nil 47 | "My custom Emacs settings" 48 | :group 'emacs) 49 | ;; Shortcut to open custom settings: 50 | (defun my/custom-settings () 51 | "Open the Emacs customization interface for my custom settings." 52 | (interactive) 53 | (customize-group 'my/custom-settings)) 54 | (defalias 'my/settings 'my/custom-settings) 55 | 56 | ;; Global minor modes 57 | (column-number-mode) 58 | (save-place-mode t) 59 | (savehist-mode t) 60 | (recentf-mode t) 61 | (electric-pair-mode t) 62 | 63 | ;; Function to add a directory to PATH and exec-path 64 | (defun my/add-exec-path (dir) 65 | "Add DIR to the environment PATH and exec-path if not already present." 66 | (unless (member dir exec-path) 67 | (setenv "PATH" (concat dir path-separator (getenv "PATH"))) 68 | (add-to-list 'exec-path dir))) 69 | 70 | (defun my/shell-execute (command &optional interactive) 71 | "Run a given shell COMMAND in a new buffer and display its output." 72 | (interactive) 73 | (let* ((command-name (car (split-string command))) 74 | (buffer-name (generate-new-buffer-name (concat "*" command-name " Output*"))) 75 | (buffer (get-buffer-create buffer-name))) 76 | (with-current-buffer buffer 77 | (erase-buffer) 78 | (insert "## Running shell process ...\n")) 79 | (start-process-shell-command 80 | command 81 | buffer 82 | command) 83 | (pop-to-buffer buffer))) 84 | 85 | (defun my/bootstrap-straight (&rest _) 86 | "Bootstrap straight.el only if it's not already installed." 87 | (unless (bound-and-true-p straight--build-dir) 88 | (let ((bootstrap-file 89 | (expand-file-name "straight/repos/straight.el/bootstrap.el" 90 | user-emacs-directory)) 91 | (bootstrap-version 5)) 92 | (unless (file-exists-p bootstrap-file) 93 | (with-current-buffer 94 | (url-retrieve-synchronously 95 | "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" 96 | 'silent 97 | 'inhibit-cookies) 98 | (goto-char (point-max)) 99 | (eval-print-last-sexp) 100 | )) 101 | (load bootstrap-file nil 'nomessage) 102 | (setq straight-use-package-by-default t) 103 | (straight-use-package 'use-package)))) 104 | ;; Advise `use-package` to initialize straight.el when first called 105 | (advice-add 'use-package :before #'my/bootstrap-straight) 106 | 107 | (defvar my/use-package-tracked-list nil 108 | "A list to track the names of packages declared via `use-package`.") 109 | (defun my/use-package-tracked-list () 110 | "Display the tracked `use-package` packages in a new buffer, one per line. 111 | If the buffer already exists, delete it and recreate it." 112 | (interactive) 113 | (let ((buffer-name "*Tracked Packages*")) 114 | (when (get-buffer buffer-name) 115 | (kill-buffer buffer-name)) 116 | (let ((buffer (get-buffer-create buffer-name))) 117 | (with-current-buffer buffer 118 | (erase-buffer) 119 | (insert "# Packages tracked via use-package:\n") 120 | (if my/use-package-tracked-list 121 | (dolist (pkg (sort my/use-package-tracked-list #'string<)) 122 | (insert (format "%s\n" pkg))) 123 | (insert "No packages tracked.\n")) 124 | (read-only-mode 1)) 125 | (pop-to-buffer buffer)))) 126 | (defun my/use-package-advice (orig-fun &rest args) 127 | "Advice around `use-package' to track package names." 128 | (when (symbolp (car args)) 129 | (push (symbol-name (car args)) my/use-package-tracked-list) 130 | (setq my/use-package-tracked-list (delete-dups my/use-package-tracked-list))) 131 | (apply orig-fun args)) 132 | 133 | (advice-add 'use-package :around #'my/use-package-advice) 134 | 135 | ;; Customize which emacs config modules to load on a per-machine basis: 136 | (defcustom my/machine-labels '() 137 | "List of machine-specific labels to configure which modules to load." 138 | :type '(repeat string) 139 | :group 'my/custom-settings) 140 | (defun my/machine-labels () 141 | "Return the list of machine-specific labels." 142 | (interactive) 143 | my/machine-labels) 144 | (defun my/machine-has-label (label) 145 | "Check if the current machine is labeled with LABEL." 146 | (if (member label my/machine-labels) 147 | t 148 | nil)) 149 | (defun my/machine-labels-available () 150 | "List all available machine labels" 151 | (let ((modules-dir (expand-file-name "modules" user-emacs-directory))) 152 | (cl-sort (mapcar #'file-name-nondirectory 153 | (seq-filter #'file-directory-p 154 | (directory-files modules-dir t "^[^.]" t))) #'string<))) 155 | (defun my/machine-labels-enable-all nil 156 | "Adds ALL existing machine labels to the custom my/machine-labels" 157 | (interactive) 158 | (let ((modules-dir (expand-file-name "modules" user-emacs-directory))) 159 | (when (y-or-n-p (format "Do you want to enable ALL Emacs modules from %s? " modules-dir)) 160 | (progn 161 | (customize-set-variable 'my/machine-labels (my/machine-labels-available)) 162 | (customize-save-customized))))) 163 | 164 | (defvar my/modules-dir (expand-file-name "modules/" user-emacs-directory)) 165 | (defvar my/module-priority-list '("general" "fonts") 166 | "List of prioritized modules to install first.") 167 | (defun my/load-modules (requested-modules) 168 | "Load user-requested modules in a priority order. 169 | REQUESTED-MODULES is a list of module names to load." 170 | ;; Find and load all single file modules and load them regardless of any config 171 | ;; (these onesshouldn't have any extra dependencies) 172 | (when (file-directory-p my/modules-dir) 173 | (let ((files (directory-files my/modules-dir t "\\.el\\'"))) 174 | (dolist (file (sort files #'string<)) 175 | (message "Loading module: %s" file) 176 | (condition-case err 177 | (load file nil 'nomessage) 178 | (error (message "Error loading %s: %s" file err)))))) 179 | ;; Prioritize and install the requested third party / optional modules: 180 | (let ((prioritized-modules 181 | (seq-filter (lambda (mod) (member mod my/module-priority-list)) 182 | requested-modules)) 183 | (remaining-modules 184 | (seq-remove (lambda (mod) (member mod my/module-priority-list)) 185 | requested-modules))) 186 | ;; Sort prioritized modules based on `my/module-priority-list` 187 | (setq prioritized-modules 188 | (sort prioritized-modules 189 | (lambda (a b) 190 | (< (or (cl-position a my/module-priority-list) 191 | most-positive-fixnum) 192 | (or (cl-position b my/module-priority-list) 193 | most-positive-fixnum))))) 194 | ;; Combine prioritized and remaining modules 195 | (let ((ordered-modules (append prioritized-modules 196 | remaining-modules))) 197 | (dolist (mod ordered-modules) 198 | (let ((mod-path (expand-file-name mod my/modules-dir))) 199 | (if (file-directory-p mod-path) 200 | (progn 201 | (message "Loading module: %s" mod) 202 | (let ((files (directory-files mod-path t "\\.el\\'"))) 203 | (dolist (file (sort files #'string<)) 204 | (condition-case err 205 | (load file nil 'nomessage) 206 | (error (message "Error loading %s: %s" file err)))))) 207 | (message "Skipping module: %s (not found)" mod))))))) 208 | 209 | ;; load the modules configured for this macchine 210 | (my/load-modules my/machine-labels) 211 | 212 | ;; Install rust dependencies that were declared by modules 213 | (when my/cargo-dependencies 214 | (my/cargo-install my/cargo-dependencies)) 215 | -------------------------------------------------------------------------------- /modules/ace-window/ace-window.el: -------------------------------------------------------------------------------- 1 | (use-package ace-window 2 | :general ("C-x o" 'ace-window)) 3 | -------------------------------------------------------------------------------- /modules/avy/avy.el: -------------------------------------------------------------------------------- 1 | ;; Avy (like ace-jump) :: https://github.com/abo-abo/avy 2 | (use-package 3 | avy 4 | :general 5 | ;;; These are if you want to use avy by itself, 6 | ;;; Otherwise these keys will be defined by treesit-jump instead. 7 | ("s-s" 'avy-goto-word-1) 8 | ("C-c s" 'avy-goto-char) 9 | ("C-c S" 'avy-goto-word-1)) 10 | -------------------------------------------------------------------------------- /modules/cargo.el: -------------------------------------------------------------------------------- 1 | (my/add-exec-path "~/.cargo/bin") 2 | (unless (executable-find "cargo") 3 | (message "cargo binary NOT found.")) 4 | 5 | (require 'seq) 6 | (require 'comint) 7 | 8 | (defun my/cargo-package-installed-p (package) 9 | "Check if a given cargo PACKAGE is installed. 10 | PACKAGE can be either a string or a cons cell (CRATE . GIT-URL). 11 | In either case, this function uses the crate name for the check." 12 | (let ((pkg (if (consp package) (car package) package))) 13 | (with-temp-buffer 14 | (when (eq 0 (call-process "cargo" nil t nil "install" "--list")) 15 | (goto-char (point-min)) 16 | (search-forward pkg nil t))))) 17 | (defun my/cargo-install (programs) 18 | "Install a list of PROGRAMS via `cargo install`, skipping those already installed. 19 | PROGRAMS can be: 20 | - a single string (with space-separated program names), 21 | - a list of strings, 22 | - or a list where some elements are cons cells (CRATE . GIT-REPO). 23 | 24 | For cons cell entries, Cargo is invoked with the --git flag." 25 | (unless programs 26 | (user-error "No programs specified for cargo install")) 27 | ;; If PROGRAMS is a string, split it into a list. 28 | (setq programs (if (stringp programs) 29 | (split-string programs) 30 | programs)) 31 | ;; Remove already installed programs. 32 | (setq programs (seq-remove #'my/cargo-package-installed-p programs)) 33 | ;; Separate into two groups: 34 | ;; - crates from crates.io (plain strings or cons cells treated as a name only) 35 | ;; - git dependencies (explicit cons cells) 36 | (let ((crate-names (mapcar (lambda (dep) 37 | (if (consp dep) 38 | (car dep) 39 | dep)) 40 | (seq-filter (lambda (dep) 41 | (not (consp dep))) 42 | programs))) 43 | (git-deps (seq-filter #'consp programs))) 44 | ;; Install crates from crates.io in one command, if any. 45 | (when crate-names 46 | (let ((command (concat "cargo install " (string-join crate-names " ")))) 47 | (my/shell-execute command))) 48 | ;; Install each git dependency separately. 49 | (dolist (dep git-deps) 50 | (let* ((crate (car dep)) 51 | (git-repo (cdr dep)) 52 | (command (format "cargo install %s --git %s" crate git-repo))) 53 | (my/shell-execute command))))) 54 | (defvar my/cargo-dependencies nil 55 | "A list of Rust crate dependencies to be installed. 56 | Each dependency is either a crate name (a symbol or string) or a cons cell 57 | of the form (CRATE . GIT-REPO).") 58 | 59 | (defun my/cargo-dependency (crate &optional git-repo) 60 | "Add a Rust CRATE to the list of dependencies. 61 | If GIT-REPO is provided, the dependency is stored as (CRATE . GIT-REPO). 62 | Otherwise, only CRATE is stored. 63 | If the dependency (by crate name) already exists, do nothing." 64 | (unless (cl-find crate my/cargo-dependencies 65 | :test (lambda (d c) 66 | (if (consp d) 67 | (equal (car d) c) 68 | (equal d c)))) 69 | (push (if git-repo (cons crate git-repo) crate) 70 | my/cargo-dependencies))) 71 | -------------------------------------------------------------------------------- /modules/completion/completion.el: -------------------------------------------------------------------------------- 1 | ;; Allow minibuffers to stack: 2 | (setq-default enable-recursive-minibuffers t) 3 | ;; Filter command completions to only include commands 4 | ;; applicable to the current major mode: 5 | (setq-default read-extended-command-predicate 6 | #'command-completion-default-include-p) 7 | ;; Add custom prompt when asking for multiple values as (comma) separated list: 8 | (advice-add #'completing-read-multiple :filter-args 9 | (lambda (args) 10 | (cons (format "[CRM%s] %s" 11 | (replace-regexp-in-string 12 | "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" 13 | crm-separator) 14 | (car args)) 15 | (cdr args)))) 16 | ;; Do not allow the cursor in the minibuffer prompt 17 | (setq minibuffer-prompt-properties 18 | '(read-only t cursor-intangible t face minibuffer-prompt)) 19 | (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) 20 | (use-package 21 | consult 22 | :general ("C-x b" 'consult-buffer) 23 | (setq consult-buffer-sources 24 | '(consult--source-buffers 25 | consult--source-recent-file 26 | consult--source-project-buffer))) 27 | 28 | (use-package vertico 29 | :custom 30 | (vertico-scroll-margin 2) 31 | (vertico-count 10) 32 | (vertico-resize 'grow-only) 33 | (vertico-cycle nil) 34 | :init 35 | ;;(keymap-set vertico-map "?" #'minibuffer-completion-help) 36 | ;;(keymap-set vertico-map "M-TAB" #'vertico-insert) 37 | ;;(keymap-set vertico-map "TAB" #'minibuffer-complete) 38 | (vertico-mode)) 39 | 40 | (use-package orderless 41 | :custom 42 | ;; Configure a custom style dispatcher (see the Consult wiki) 43 | ;; (orderless-style-dispatchers 44 | ;; '(+orderless-consult-dispatch orderless-affix-dispatch)) 45 | ;; (orderless-component-separator #'orderless-escapable-split-on-space) 46 | (completion-styles '(orderless basic)) 47 | (completion-category-defaults nil) 48 | (completion-category-overrides '((file (styles partial-completion))))) 49 | 50 | (use-package marginalia 51 | :hook 52 | ((marginalia-mode . all-the-icons-completion-marginalia-setup)) 53 | :bind (:map minibuffer-local-map 54 | ("M-A" . marginalia-cycle)) 55 | :init 56 | (marginalia-mode)) 57 | 58 | (use-package nerd-icons-completion 59 | :init 60 | (nerd-icons-completion-mode)) 61 | 62 | (use-package company) 63 | -------------------------------------------------------------------------------- /modules/dashboard/dashboard.el: -------------------------------------------------------------------------------- 1 | (use-package 2 | dashboard 3 | :init 4 | (defun my-dashboard-insert-vocabulary (list-size) 5 | (when (fboundp 'latin-word-of-the-day) 6 | (dashboard-insert-heading "Word of the day:" nil) 7 | (insert "\n") 8 | (let* ((char-limit 100000) 9 | (word (latin-word-of-the-day)) 10 | (description (latin-word-get-description word))) 11 | (insert 12 | (substring description 13 | 0 14 | (min char-limit (length description))))))) 15 | (dashboard-setup-startup-hook) 16 | :hook 17 | ((dashboard-mode . (lambda () (setq-local show-trailing-whitespace nil)))) 18 | :custom 19 | (dashboard-center-content t) 20 | (dashboard-set-heading-icons nil) 21 | (dashboard-set-file-icons nil) 22 | (dashboard-icon-type nil) 23 | (dashboard-footer-messages (list " ")) 24 | (dashboard-items '((recents . 5) (bookmarks . 5) (vocabulary))) 25 | (dashboard-startup-banner (+ 1 (random 3))) 26 | (dashboard-item-generators 27 | '((vocabulary . my-dashboard-insert-vocabulary) 28 | (recents . dashboard-insert-recents) 29 | (bookmarks . dashboard-insert-bookmarks)))) 30 | -------------------------------------------------------------------------------- /modules/fonts/fonts.el: -------------------------------------------------------------------------------- 1 | ;;; Download JetBrains Mono typeface 2 | (let* ((url "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.3.0/JetBrainsMono.zip") 3 | (zip-file (expand-file-name "JetBrainsMono.zip" temporary-file-directory)) 4 | (font-dir (expand-file-name "~/.local/share/fonts/JetBrainsMonoNerdFont/")) 5 | (default-directory temporary-file-directory)) 6 | (unless (file-directory-p font-dir) 7 | (url-copy-file url zip-file t) 8 | (make-directory font-dir t) 9 | (let ((output-buffer (generate-new-buffer "*unzip-output*"))) 10 | (unwind-protect 11 | (call-process "unzip" 12 | nil output-buffer nil "-j" zip-file "-d" font-dir) 13 | (kill-buffer output-buffer))) 14 | (call-process "fc-cache" nil nil nil "-fv") 15 | (delete-file zip-file) 16 | (message "JetBrains Mono Nerd Font installed successfully."))) 17 | 18 | ;;; show list of installed fonts: 19 | ;;(font-family-list) 20 | ;;; show default font: 21 | ;;(face-attribute 'default :font) 22 | ;;; Set default font faces: 23 | ;; M-x my/custom-settings :: font-settings group: 24 | (defgroup my/font-settings nil 25 | "My custom font settings" 26 | :group 'my/custom-settings) 27 | (defcustom my/font-family-default "JetBrainsMono Nerd Font" 28 | "Default font family" 29 | :type 'string 30 | :group 'my/font-settings) 31 | (defcustom my/font-size-default 120 32 | "Default font size" 33 | :type 'string 34 | :group 'my/font-settings) 35 | (defun my/font-settings-apply () 36 | "Set the default font based on 37 | `my/font-family-default` and `my/font-size-default`." 38 | (set-face-attribute 'default nil 39 | :family my/font-family-default 40 | :height my/font-size-default) 41 | t) 42 | (my/font-settings-apply) 43 | (add-hook 'after-init-hook #'my/font-settings-apply) 44 | (advice-add 'custom-save-all :after (lambda () 45 | "Re-apply custom settings after saving customizations." 46 | (my/font-settings-apply))) 47 | 48 | ;; Use nerd icons 49 | (use-package nerd-icons 50 | :custom 51 | (nerd-icons-font-family "JetBrainsMono Nerd Font")) 52 | 53 | (use-package show-font) 54 | -------------------------------------------------------------------------------- /modules/general/general.el: -------------------------------------------------------------------------------- 1 | (use-package 2 | general 3 | :init 4 | ;; Switch between two most recent buffers: 5 | (fset 'quick-switch-buffer [?\C-x ?b return]) 6 | :config 7 | ;;; Custom global bindings: 8 | (general-define-key 9 | "C-h B" 'general-describe-keybindings 10 | "s-b" 'quick-switch-buffer 11 | "s-B" 'buffer-menu-other-window 12 | "C-x B" 'buffer-menu-other-window 13 | "s-o" 'browse-url 14 | "C-;" 'comment-region ; C-u C-; to uncomment 15 | "s-" 'mouse-drag-region-rectangle 16 | "C-x j" 'jump-to-register 17 | "C-c j" 'jump-to-register 18 | "C-" 'my/register-jump-f1 19 | "M-" 'my/register-save-f1 20 | "C-" 'my/register-jump-f2 21 | "M-" 'my/register-save-f2 22 | "C-" 'my/register-jump-f3 23 | "M-" 'my/register-save-f3 24 | "C-" 'my/register-jump-f4 25 | "M-" 'my/register-save-f4 26 | ) 27 | ;;; Put the Emacs default keybindings you want included 28 | ;;; in general-describe-keybindings here: 29 | ;;; Its useful to duplicate these simply as a way of documentation: 30 | (general-define-key 31 | "M-SPC" 'cycle-spacing ; If you document it, you will use it. 32 | "M-h" 'mark-paragraph ; C-h B is like your personal cheat sheet. 33 | "C-h b" 'describe-bindings ;; default binding for documentation purpose 34 | "C-x 4 c" 'clone-indirect-buffer-other-window ;; default binding 35 | ) 36 | ;;; Define bindings for specific builtin (non use-package) modes: 37 | ;; Emacs Lisp mode bindings: 38 | (general-define-key 39 | :keymaps 'emacs-lisp-mode-map 40 | "s-e" 'eval-defun ;eval top-level form 41 | "M-;" 'paredit-comment-dwim) 42 | ;; Dired mode bindings: 43 | (general-define-key 44 | :keymaps 'dired-mode-map "C-c C-q" 'dired-toggle-read-only)) 45 | -------------------------------------------------------------------------------- /modules/git.el: -------------------------------------------------------------------------------- 1 | ;;; function to determine the current git branch -- ignore this in context 2 | (defun my/emacs-git-branch () 3 | (substring (shell-command-to-string "git branch --show-current") 0 -1)) 4 | -------------------------------------------------------------------------------- /modules/gptel/gptel.el: -------------------------------------------------------------------------------- 1 | (use-package 2 | gptel 3 | :general 4 | ("C-c C-g" 'gptel-menu) 5 | (:keymaps 'gptel-mode-map "C-c C-c" 'gptel-send) 6 | :config (add-hook 'gptel-post-response-functions 'gptel-end-of-response) 7 | ;(add-hook 'gptel-post-stream-hook 'gptel-auto-scroll) 8 | (setq gptel-org-branching-context t) 9 | :init 10 | ;; LM-studio offers an OpenAI compatible API 11 | (setq 12 | gptel-model 'test 13 | gptel-backend 14 | (gptel-make-openai 15 | "lm-studio" 16 | :stream t 17 | :protocol "http" 18 | :host "localhost:1234" 19 | :models '(test)))) 20 | -------------------------------------------------------------------------------- /modules/just/just.el: -------------------------------------------------------------------------------- 1 | ;; depend on the just crate so its installed automatically 2 | ;; you must add "just" to the list of my/machine-labels for this to work: 3 | (my/cargo-dependency "just") 4 | 5 | ;; just-mode 6 | (use-package just-mode) 7 | -------------------------------------------------------------------------------- /modules/latin-words/latin-words.el: -------------------------------------------------------------------------------- 1 | (use-package 2 | latin-words 3 | :straight 4 | (latin-words :type git :host github :repo "enigmacurry/latin-words") 5 | :custom 6 | (latin-words-directory 7 | (expand-file-name "straight/repos/latin-words/data" user-emacs-directory))) 8 | -------------------------------------------------------------------------------- /modules/lsp/lsp.el: -------------------------------------------------------------------------------- 1 | ;; LSP mode :: https://emacs-lsp.github.io/lsp-mode/ 2 | (use-package 3 | lsp-mode 4 | :init 5 | ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l") 6 | (setq lsp-keymap-prefix "C-c l") 7 | (setq lsp-modeline-diagnostics-scope :workspace) 8 | ;;; extra verbose logging of lsp json messages: 9 | ;;(setq lsp-log-io t) 10 | :hook 11 | ((web-mode . lsp) 12 | ;(lsp-mode . lsp-enable-which-key-integration) 13 | (python-mode . lsp-deferred)) 14 | :commands lsp 15 | :config) 16 | (use-package lsp-ui :commands lsp-ui-mode) 17 | (use-package lsp-ivy :commands lsp-ivy-workspace-symbol) 18 | (use-package lsp-treemacs :commands lsp-treemacs-errors-list) 19 | (use-package flycheck) 20 | 21 | ;; LSP debuggers 22 | (use-package dap-mode) 23 | ;; (use-package dap-LANGUAGE) to load the dap adapter for your language 24 | -------------------------------------------------------------------------------- /modules/magit/magit.el: -------------------------------------------------------------------------------- 1 | ;; Magit (git version control system) :: https://magit.vc/ 2 | (use-package 3 | magit 4 | :general ("C-c g" 'magit-status) 5 | :config 6 | ;; open magit in a full frame always: 7 | (setq magit-display-buffer-function 8 | #'magit-display-buffer-fullframe-status-v1)) 9 | -------------------------------------------------------------------------------- /modules/markdown/markdown.el: -------------------------------------------------------------------------------- 1 | (use-package markdown-mode) 2 | -------------------------------------------------------------------------------- /modules/org/org-mode-unpackaged.el: -------------------------------------------------------------------------------- 1 | ;; This is a modified portion of unpackaged.el 2 | ;; 3 | ;; Copyright (C) 2018 Adam Porter 4 | ;; URL: https://github.com/alphapapa/unpackaged.el 5 | ;; 6 | ;;; License: 7 | ;; This program is free software; you can redistribute it and/or modify 8 | ;; it under the terms of the GNU General Public License as published by 9 | ;; the Free Software Foundation, either version 3 of the License, or 10 | ;; (at your option) any later version. 11 | ;; 12 | ;; This program is distributed in the hope that it will be useful, 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ;; GNU General Public License for more details. 16 | ;; 17 | ;; You should have received a copy of the GNU General Public License 18 | ;; along with this program. If not, see . 19 | 20 | (require 'cl-lib) 21 | (define-minor-mode unpackaged/org-export-html-with-useful-ids-mode 22 | "Attempt to export Org as HTML with useful link IDs. 23 | Instead of random IDs like \"#orga1b2c3\", use heading titles, 24 | made unique when necessary." 25 | :global t 26 | (if unpackaged/org-export-html-with-useful-ids-mode 27 | (advice-add #'org-export-get-reference :override 28 | #'unpackaged/org-export-get-reference) 29 | (advice-remove #'org-export-get-reference 30 | #'unpackaged/org-export-get-reference))) 31 | (defun unpackaged/org-export-get-reference (datum info) 32 | "Like `org-export-get-reference', 33 | except uses heading titles instead of random numbers." 34 | (let ((cache (plist-get info :internal-references))) 35 | (or (car (rassq datum cache)) 36 | (let* ((crossrefs (plist-get info :crossrefs)) 37 | (cells (org-export-search-cells datum)) 38 | ;; Preserve any pre-existing association between 39 | ;; a search cell and a reference. 40 | (new (or (cl-some 41 | (lambda (cell) 42 | (let ((stored (cdr (assoc cell crossrefs)))) 43 | (when stored 44 | (let ((old (org-export-format-reference stored))) 45 | (and (not (assoc old cache)) stored))))) 46 | cells) 47 | (when (org-element-property :raw-value datum) 48 | ;; Heading with a title 49 | (unpackaged/org-export-new-title-reference datum cache)) 50 | ;; Generate new reference 51 | (org-export-format-reference 52 | (org-export-new-reference cache)))) 53 | (reference-string (replace-regexp-in-string "%20" "_" new))) 54 | ;; Cache contains both data already associated to 55 | ;; a reference and in-use internal references, so as to make 56 | ;; unique references. 57 | (dolist (cell cells) (push (cons cell new) cache)) 58 | ;; Retain a direct association between reference string and DATUM. 59 | (push (cons reference-string datum) cache) 60 | (plist-put info :internal-references cache) 61 | reference-string)))) 62 | (defun unpackaged/org-export-new-title-reference (datum cache) 63 | "Return new reference for DATUM that is unique in CACHE." 64 | (cl-macrolet ((inc-suffixf (place) 65 | `(progn 66 | (string-match (rx bos 67 | (minimal-match (group (1+ anything))) 68 | (optional "--" (group (1+ digit))) 69 | eos) 70 | ,place) 71 | ;; HACK: `s1' instead of a gensym. 72 | (-let* (((s1 suffix) (list (match-string 1 ,place) 73 | (match-string 2 ,place))) 74 | (suffix (if suffix 75 | (string-to-number suffix) 76 | 0))) 77 | (setf ,place (format "%s--%s" s1 (cl-incf suffix))))))) 78 | (let* ((title (org-element-property :raw-value datum)) 79 | (ref (url-hexify-string (substring-no-properties title))) 80 | (parent (org-element-property :parent datum))) 81 | (while (cl-some (lambda (it) (equal ref (car it))) cache) 82 | ;; Title not unique: make it so. 83 | (if parent 84 | ;; Append ancestor title. 85 | (setf title (concat (org-element-property :raw-value parent) 86 | "--" title) 87 | ref (url-hexify-string (substring-no-properties title)) 88 | parent (org-element-property :parent parent)) 89 | ;; No more ancestors: add and increment a number. 90 | (inc-suffixf ref))) 91 | ref))) 92 | -------------------------------------------------------------------------------- /modules/org/org.el: -------------------------------------------------------------------------------- 1 | ;; hydra (rapid fire mnemonic keybindings) :: https://github.com/abo-abo/hydra 2 | (use-package hydra) 3 | (use-package org 4 | :after hydra 5 | :hook ((org-mode . flyspell-mode) 6 | (org-mode . unpackaged/org-export-html-with-useful-ids-mode)) 7 | :custom 8 | (org-html-validation-link nil) 9 | (org-html-use-infojs nil) 10 | (org-html-postamble 'auto) 11 | (org-export-with-author t) 12 | (org-export-with-date t) 13 | (org-export-with-creator nil) 14 | (org-export-with-email nil) 15 | (org-export-timestamp-file t) 16 | (org-export-allow-bind-keywords t) 17 | (org-directory "~/Org") 18 | :general 19 | ("s-" 'org-previous-visible-heading) 20 | ("s-" 'org-next-visible-heading) 21 | ("C-c o k" 'org-babel-remove-result) 22 | :config 23 | (setq org-startup-folded t) 24 | (defun my-org-html--translate (original-function keyword info) 25 | "Custom advice to translate the keyword 'Created' to 'Last Modified'." 26 | (if (string-equal keyword "Created") 27 | "Last Modified" 28 | (funcall original-function keyword info))) 29 | (advice-add 'org-html--translate :around #'my-org-html--translate) 30 | (org-babel-do-load-languages 31 | 'org-babel-load-languages 32 | '((python . t) (scheme . t) (shell . t) (ditaa . t))) 33 | :init 34 | (defcustom my/org-notes-directory "~/Org/notes" "My org notes directory") 35 | (defcustom my/org-notes-export-directory "~/Org/export/notes" "My org notes HTML export directory") 36 | ;; Hydra for commonly used org commands: 37 | (defhydra 38 | hydra-org 39 | (global-map "C-c o" :exit t color pink :hint nil) 40 | "Org commands:" 41 | ("o" my/org-open-file) 42 | ("l" org-store-link "store link") 43 | ("i" org-insert-link "insert link") 44 | ("a" org-agenda "agenda") 45 | ("c" org-capture "capture") 46 | ("m" org-info "read info manual") 47 | ("e" org-export-dispatch "export") 48 | ("p" org-preview-html-mode "toggle preview mode") 49 | ("s" org-insert-source-code-block "insert source code block")) 50 | ) 51 | (require 'org-tempo) ; required for Structure Templates 52 | ; See https://orgmode.org/manual/Structure-Templates.html 53 | (use-package htmlize) ; required for colorized HTML code blocks 54 | (use-package org-preview-html :after org) 55 | (use-package ob-async) 56 | (progn ; electic pairs for org-mode 57 | (modify-syntax-entry ?/ "\"" org-mode-syntax-table) 58 | (modify-syntax-entry ?* "\"" org-mode-syntax-table) 59 | (modify-syntax-entry ?= "\"" org-mode-syntax-table) 60 | (modify-syntax-entry ?+ "\"" org-mode-syntax-table) 61 | (modify-syntax-entry ?_ "\"" org-mode-syntax-table) 62 | (modify-syntax-entry ?~ "\"" org-mode-syntax-table)) 63 | 64 | (defcustom my/org-html-theme "simple_dark" "the name of my custom org theme (CSS)") 65 | (defun my/emacs-org-tangle () 66 | "Tangle all code blocks in 'emacs.org' and export this document to HTML." 67 | (let* ((org-file (expand-file-name "emacs.org" user-emacs-directory)) 68 | (modules-dir (expand-file-name "modules" user-emacs-directory)) 69 | (export-dir (expand-file-name my/org-notes-export-directory)) 70 | (export-emacs-dir (expand-file-name "emacs" export-dir)) 71 | (export-file (expand-file-name "index.html" user-emacs-directory))) 72 | (when (file-exists-p org-file) 73 | (with-current-buffer (find-file-noselect org-file) 74 | (delete-directory modules-dir t) 75 | (org-babel-tangle) 76 | (org-export-to-file 'html export-file) 77 | (unless (file-directory-p export-dir) 78 | (make-directory export-dir t)) 79 | (unless (file-directory-p export-emacs-dir) 80 | (make-directory export-emacs-dir t)) 81 | (my/org-create-theme-file) 82 | (make-symbolic-link "index.html" "emacs.html" t) 83 | (make-symbolic-link (expand-file-name "index.html" user-emacs-directory) (expand-file-name "index.html" export-emacs-dir) t) 84 | (make-symbolic-link (expand-file-name "index.html" user-emacs-directory) (expand-file-name "emacs.html" export-emacs-dir) t) 85 | (make-symbolic-link (expand-file-name "early-init.el" user-emacs-directory) (expand-file-name "early-init.el" export-emacs-dir) t) 86 | (make-symbolic-link (expand-file-name "init.el" user-emacs-directory) (expand-file-name "init.el" export-emacs-dir) t) 87 | (make-symbolic-link (expand-file-name "modules" user-emacs-directory) (expand-file-name "modules" export-emacs-dir) t) 88 | (make-symbolic-link (expand-file-name "LICENSE.txt" user-emacs-directory) (expand-file-name "LICENSE.txt" export-emacs-dir) t) 89 | (make-symbolic-link (expand-file-name "LICENSE_GPLv3.txt" user-emacs-directory) (expand-file-name "LICENSE_GPLv3.txt" export-emacs-dir) t) 90 | (make-symbolic-link (expand-file-name "theme" user-emacs-directory) (expand-file-name "theme" export-dir) t) 91 | (make-symbolic-link (expand-file-name "theme" user-emacs-directory) (expand-file-name "theme" my/org-notes-directory) t) 92 | )))) 93 | (with-eval-after-load 'ox-html 94 | (defun my/org-html-src-block (orig-fun src-block contents info) 95 | "Advice for `org-html-src-block' to add a header. 96 | If a :tangle header is specified (and not \"no\"), it shows the tangle file. 97 | If the block is a shell block, it prints 'Run in Bash shell:'. 98 | Otherwise, it prints the code block's language. 99 | ORIG-FUN is the original function; SRC-BLOCK is the source block; 100 | INFO is the export options plist." 101 | (let* ((parameters (org-element-property :parameters src-block)) 102 | (header-args (org-babel-parse-header-arguments parameters)) 103 | (tangle (cdr (assoc :tangle header-args))) 104 | (lang (org-element-property :language src-block)) 105 | (header (cond 106 | ((and tangle (not (string= tangle "no"))) 107 | (format "
:tangle %s
\n" 108 | (org-html-encode-plain-text tangle))) 109 | ((string= lang "shell") 110 | "
Run this in your shell ::
\n") 111 | ((string= lang "example") 112 | "
Example ::
\n") 113 | (lang 114 | (format "
(untangled) %s
\n" 115 | (org-html-encode-plain-text lang))) 116 | (t ""))) 117 | (code (funcall orig-fun src-block contents info))) 118 | (if (not (string= header "")) 119 | (format "
%s%s
" header code) 120 | code))) 121 | (advice-add 'org-html-src-block :around #'my/org-html-src-block)) 122 | 123 | ;; Tell Emacs to trust this code in all buffer local vars: 124 | (add-to-list 'safe-local-variable-values 125 | '(eval add-hook 'after-save-hook 'my/emacs-org-tangle nil t)) 126 | (add-to-list 'safe-local-variable-values 127 | '(org-confirm-babel-evaluate)) 128 | 129 | (my/cargo-dependency "live-server") ; defers install of live-server Rust crate 130 | (defvar my/org-html-server-host "127.0.0.1") ; Set to 0.0.0.0 to serve publicly 131 | (defvar my/org-html-server-port "7776") 132 | (defun my/org-html-server (&optional redirect) 133 | "Start a local live-server for my org notes. 134 | If the server is already running, open the URL." 135 | (interactive) 136 | (let* ((host my/org-html-server-host) 137 | (port my/org-html-server-port) 138 | (redirect (or redirect "")) 139 | (url (format "http://%s:%s/%s" host port redirect)) 140 | (live-server-proc (get-process "live-server"))) 141 | (if (and live-server-proc (process-live-p live-server-proc)) 142 | (progn 143 | (message "live-server already running; opening %s" url) 144 | (browse-url url)) 145 | (let ((live-server-path (executable-find "live-server")) 146 | (log-buffer-name "*my/org-html-server*") 147 | (export-dir (expand-file-name my/org-notes-export-directory))) 148 | (with-current-buffer (get-buffer-create log-buffer-name) 149 | (if live-server-path 150 | (progn 151 | (message "live-server found at: %s" live-server-path) 152 | (start-process "live-server" log-buffer-name "live-server" 153 | "-H" host "-p" port "-o" redirect export-dir) 154 | (message "Started live-server on %s" url)) 155 | (message "live-server NOT found – please run: cargo install live-server"))))))) 156 | (defun my/emacs-org-html-server () 157 | "Start a local live-server and redirect to the emacs page" 158 | (interactive) 159 | (my/org-html-server "emacs")) 160 | (defun my/org-notes-html-server () 161 | "Start a local live-server and redirect to the current Org note file. 162 | If the current buffer is an Org file in `my/org-notes-directory`, tangle 163 | it and export to HTML before serving it." 164 | (interactive) 165 | (let ((org-file (buffer-file-name))) 166 | (if (and org-file 167 | (string= "org" (file-name-extension org-file)) 168 | (string-prefix-p (expand-file-name my/org-notes-directory) (expand-file-name org-file))) 169 | (let ((html-file (concat (file-name-sans-extension org-file) ".html"))) 170 | (my/org-babel-tangle org-file) 171 | (my/org-html-server (file-name-nondirectory html-file))) 172 | (message "Current buffer is not an Org file in %s" my/org-notes-directory)))) 173 | 174 | (defcustom my/org-template 175 | (concat "#+TITLE: {{title}}\n" 176 | "#+PROPERTY: header-args :exports both :results both :eval never-export\n" 177 | "#+OPTIONS: noweb:t\n") 178 | "My default Org template.") 179 | 180 | (defun my/org-create-theme-file () 181 | "Create the theme file in the 'theme' directory under `user-emacs-directory`. 182 | This file wraps the contents of the theme CSS (also in the theme directory) 183 | with HTML \n") 199 | theme-file))) 200 | 201 | (defun my/org-open-file () 202 | "Open a new Org file with the default notes template and include the theme file. 203 | This function does the following: 204 | 1. Opens a new Org file in `org-directory/notes` and inserts the template, 205 | replacing placeholders like {{title}}, {{date}}, etc. 206 | 2. If the directory `org-directory/notes` does not exist, it is created. 207 | 3. It creates (or updates) the theme file via `my/org-create-theme-file`, which is 208 | stored in `user-emacs-directory/theme/{{theme}}.theme`. 209 | 4. The Org file then includes a line: \"#+SETUPFILE: {{theme}}.theme\" so that 210 | when you export, Org loads the theme file." 211 | (interactive) 212 | (let* ((formatted-date (format-time-string "%Y-%m-%d")) 213 | (user-title (read-string "Title for new note: ")) 214 | (safe-title (replace-regexp-in-string " " "-" (downcase user-title))) 215 | ;; Define the notes directory and ensure it exists. 216 | (notes-dir (file-name-as-directory (concat org-directory "/notes"))) 217 | (_ (unless (file-directory-p notes-dir) 218 | (make-directory notes-dir t))) 219 | (filename (format "%s/%s-%s.org" 220 | notes-dir 221 | (format-time-string "%Y-%m-%d-%H-%M-%S") 222 | safe-title)) 223 | (section (read-string "Section: " formatted-date)) 224 | (title-section (mapconcat #'capitalize (split-string section " ") " "))) 225 | (unless (file-directory-p my/org-notes-directory) 226 | (make-directory my/org-notes-directory t)) 227 | (find-file filename) 228 | (when (zerop (buffer-size)) 229 | ;; Insert the Org template with placeholders replaced. 230 | (insert 231 | (replace-regexp-in-string 232 | "{{title}}" 233 | user-title 234 | (replace-regexp-in-string 235 | "{{date}}" 236 | formatted-date 237 | (replace-regexp-in-string 238 | "{{section}}" 239 | section 240 | (replace-regexp-in-string 241 | "{{safe-title}}" 242 | safe-title 243 | (replace-regexp-in-string 244 | "{{title-section}}" 245 | title-section 246 | my/org-template)))))) 247 | ;; Create the theme file and insert the setup line. 248 | (let ((theme-file (my/org-create-theme-file))) 249 | (insert (format "#+SETUPFILE: theme/%s\n\n" 250 | (file-name-nondirectory theme-file))))))) 251 | 252 | (defun my/org-babel-tangle (org-file) 253 | "Tangle and export an Org file to HTML." 254 | (when (file-exists-p org-file) 255 | (with-current-buffer (find-file-noselect org-file) 256 | (org-babel-tangle) 257 | (my/org-create-theme-file) 258 | (org-export-to-file 'html 259 | (expand-file-name (org-export-output-file-name ".html" nil) 260 | my/org-notes-export-directory))))) 261 | 262 | (defun my/save-buffer-after-code-execution (orig-fun &rest args) 263 | "Execute ORIG-FUN with ARGS and save the buffer afterward. 264 | If the code block is executed asynchronously (i.e. returns a process), 265 | attach a sentinel so that `save-buffer` is called when the process finishes. 266 | Otherwise, call `save-buffer` immediately." 267 | (let ((result (apply orig-fun args))) 268 | (if (processp result) 269 | (set-process-sentinel 270 | result 271 | (lambda (_proc event) 272 | ;; Adjust this if your process returns a different finished event. 273 | (when (string-match-p "finished" event) 274 | (save-buffer)))) 275 | (save-buffer)) 276 | result)) 277 | (advice-add 'org-babel-execute-src-block :around #'my/save-buffer-after-code-execution) 278 | (advice-add 'rustic-babel-run-update-result-block :around #'my/save-buffer-after-code-execution) 279 | -------------------------------------------------------------------------------- /modules/programming.el: -------------------------------------------------------------------------------- 1 | ;; Basic programming mode settings 2 | (setq-default display-fill-column-indicator-column 80) 3 | (add-hook 'prog-mode-hook (lambda () 4 | (setq show-trailing-whitespace t) 5 | (display-fill-column-indicator-mode 1) 6 | (display-line-numbers-mode 1))) 7 | 8 | ;; Edit .env files with shell-script-mode 9 | (add-to-list 'auto-mode-alist '("\\.env\\'" . shell-script-mode)) 10 | (add-to-list 'auto-mode-alist '("\\.env_.*\\'" . shell-script-mode)) 11 | (add-to-list 'auto-mode-alist '("\\.env-dist\\'" . shell-script-mode)) 12 | -------------------------------------------------------------------------------- /modules/python/python.el: -------------------------------------------------------------------------------- 1 | (my/add-exec-path "~/.local/bin") 2 | (defun my/python-install-uv-package-manager () 3 | "Install uv package manager via cargo" 4 | (my/cargo-install '(("uv" . "https://github.com/astral-sh/uv")))) 5 | (defun my/python-uv-execute (command) 6 | (my/python-install-uv-package-manager) 7 | (my/shell-execute command)) 8 | (defun my/python-install-ruff () 9 | (unless (executable-find "ruff") 10 | (my/python-uv-execute "uv tool install ruff@latest"))) 11 | (use-package 12 | python-mode 13 | :general ("s-a" 'lsp-execute-code-action) 14 | :init 15 | (my/python-install-ruff) 16 | (setq auto-mode-alist 17 | (rassq-delete-all 'python-mode auto-mode-alist)) 18 | (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) 19 | (autoload 'python-mode "python-mode" "Python mode." t) 20 | :hook 21 | (python-mode . pyvenv-mode) 22 | (python-mode . flycheck-mode) 23 | (python-mode . company-mode) 24 | (python-mode . python-black-on-save-mode) 25 | :custom (python-shell-interpreter "python3") 26 | :config 27 | ;; Activate python virtualenv BEFORE opening a python buffer and/or starting pyright server: 28 | ;; M-x pyvenv-activate (~/.virtualenvs/XXX) 29 | (use-package 30 | pyvenv 31 | :init (setenv "WORKON_HOME" "~/.virtualenvs/") 32 | :config 33 | ;; (pyvenv-mode t) 34 | ;; Set correct Python interpreter 35 | (setq pyvenv-post-activate-hooks 36 | (list 37 | (lambda () 38 | (setq python-shell-interpreter 39 | (concat pyvenv-virtual-env "bin/python"))))) 40 | (setq pyvenv-post-deactivate-hooks 41 | (list (lambda () (setq python-shell-interpreter "python3"))))) 42 | ;; Black (Python code formatter) :: https://github.com/wbolster/emacs-python-black 43 | ;; Note: this depends on black being installed in the project virtualenv as a dev dependency 44 | (use-package python-black :demand t :after python) 45 | ;; Python dev dependencies need to be installed in your project's virtualenv: 46 | ;; ruff 47 | ;; ruff-lsp 48 | ;; black 49 | ;;; Add the following to a .dir-locals.el to activate virtualenv automatically: 50 | ;; ((python-mode . ((eval . (let ((project-root (locate-dominating-file 51 | ;; (or (buffer-file-name) default-directory) 52 | ;; ".dir-locals.el"))) 53 | ;; (pyvenv-activate (expand-file-name "virtualenv" project-root))))))) 54 | ) 55 | (use-package jinja2-mode) 56 | -------------------------------------------------------------------------------- /modules/registers/registers.el: -------------------------------------------------------------------------------- 1 | (defgroup my/path-settings nil 2 | "My custom path settings" 3 | :group 'my/custom-settings) 4 | (defcustom my/git-vendor-directory "~/git/vendor" 5 | "My git vendor directory" 6 | :type 'string 7 | :group 'my/path-settings) 8 | (defcustom my/git-user-directory "~/git/vendor/enigmacurry" 9 | "My personal git repositories directory" 10 | :type 'string 11 | :group 'my/path-settings) 12 | 13 | (set-register ?e `(file . ,(expand-file-name "emacs.org" user-emacs-directory))) 14 | (set-register ?o `(file . ,my/org-notes-directory)) 15 | (set-register ?g `(file . ,my/git-user-directory)) 16 | (set-register ?d `(file . ,(expand-file-name "enigmacurry/d.rymcg.tech/" my/git-vendor-directory))) 17 | (set-register ?v `(file . ,my/git-vendor-directory)) 18 | 19 | (defun my/register-save-f1 () (interactive) (point-to-register 'my/register-f1)) 20 | (defun my/register-jump-f1 () (interactive) (jump-to-register 'my/register-f1)) 21 | (defun my/register-save-f2 () (interactive) (point-to-register 'my/register-f2)) 22 | (defun my/register-jump-f2 () (interactive) (jump-to-register 'my/register-f2)) 23 | (defun my/register-save-f3 () (interactive) (point-to-register 'my/register-f3)) 24 | (defun my/register-jump-f3 () (interactive) (jump-to-register 'my/register-f3)) 25 | (defun my/register-save-f4 () (interactive) (point-to-register 'my/register-f4)) 26 | (defun my/register-jump-f4 () (interactive) (jump-to-register 'my/register-f4)) 27 | -------------------------------------------------------------------------------- /modules/rust/rust.el: -------------------------------------------------------------------------------- 1 | ;; Rust 2 | ;; must manually install cargo-watch, wasm-pack, cargo-generate 3 | (my/cargo-dependency "cargo-watch") 4 | (my/cargo-dependency "wasm-pack") 5 | (my/cargo-dependency "cargo-generate") 6 | (use-package 7 | rustic 8 | :mode ("\\.rs\\'" . rustic-mode) 9 | ;; :hook (rustic-mode . yas-minor-mode) 10 | :init 11 | (setq rustic-format-on-save t) 12 | (setq rustic-rustfmt-args "--edition 2021") 13 | (add-to-list 'exec-path "~/.cargo/bin") 14 | ;(defalias 'org-babel-execute:rust 'org-babel-execute:rustic) 15 | ;(describe-function 'org-babel-execute:rust) 16 | (add-hook 17 | 'rustic-mode-hook 18 | (lambda () 19 | (define-key 20 | rustic-mode-map 21 | (kbd "C-c M-.") 22 | 'lsp-rust-analyzer-open-external-docs)))) 23 | -------------------------------------------------------------------------------- /modules/s3-publish/s3-publish.el: -------------------------------------------------------------------------------- 1 | (use-package 2 | s3-publish 3 | :straight 4 | (s3-publish 5 | :type 6 | git 7 | :repo 8 | "https://github.com/EnigmaCurry/s3-publish.el.git") 9 | :init 10 | (require 's3-publish) 11 | :general 12 | ("C-c p" 's3-publish)) 13 | -------------------------------------------------------------------------------- /modules/sql/sql.el: -------------------------------------------------------------------------------- 1 | ;; https://github.com/purcell/sqlformat 2 | ;; https://github.com/darold/pgFormatter 3 | (use-package 4 | sqlformat 5 | :config 6 | (general-define-key 7 | :keymaps 'sql-mode-map 8 | "C-c f" 'sqlformat) 9 | :init 10 | (setq sqlformat-command 'pgformatter) 11 | (setq sqlformat-args '("-f1" "-u1")) 12 | (add-hook 'sql-mode-hook 'sqlformat-on-save-mode) 13 | ) 14 | -------------------------------------------------------------------------------- /modules/ssh-agent/ssh-agent.el: -------------------------------------------------------------------------------- 1 | ;; Load SSH / GPG keys from keychain agent 2 | (use-package 3 | keychain-environment 4 | :straight 5 | (keychain-environment 6 | :type git 7 | :files (:defaults "keychain-environment") 8 | :host github 9 | :repo "tarsius/keychain-environment") 10 | :init (keychain-refresh-environment)) 11 | -------------------------------------------------------------------------------- /modules/svelte/svelte.el: -------------------------------------------------------------------------------- 1 | (use-package svelte-mode 2 | :straight t 3 | :mode ("\\.svelte\\'" . svelte-mode) 4 | :init 5 | (use-package lsp-mode 6 | :straight t) 7 | (use-package apheleia 8 | :straight t) 9 | :hook ((svelte-mode . lsp) 10 | (svelte-mode . apheleia-mode)) 11 | :config 12 | (setq lsp-enable-snippet t) 13 | 14 | ;; Configure Apheleia to format Svelte files using Prettier v3. 15 | ;; This command passes the current file path and forces the "svelte" parser. 16 | (setf (alist-get 'svelte-mode apheleia-formatters) 17 | '("prettier" "--stdin-filepath" filepath "--parser" "svelte")) 18 | (setf (alist-get 'svelte-mode apheleia-mode-alist) 'svelte-mode) 19 | 20 | ;;(apheleia-global-mode +1) 21 | ) 22 | -------------------------------------------------------------------------------- /modules/text-scale/text-scale.el: -------------------------------------------------------------------------------- 1 | (defun my/default-text-scale-reset nil 2 | (setq default-text-scale--complement 0) 3 | (set-face-attribute 'default 4 | nil 5 | :height my/default-text-height) 6 | (message "Text height reset: %d" my/default-text-height) 7 | ) 8 | ;; Scale text sizes in all buffers :: https://github.com/purcell/default-text-scale 9 | (use-package 10 | default-text-scale 11 | :general 12 | ("C-=" 13 | 'default-text-scale-increase 14 | "C--" 15 | (lambda () 16 | "Reset text scale if C-u is used, otherwise decrease it." 17 | (interactive) 18 | (let ((prefix current-prefix-arg)) 19 | ;; Intercept and clear the prefix argument before calling the function 20 | (setq current-prefix-arg nil) 21 | (if prefix 22 | (my/default-text-scale-reset) 23 | (default-text-scale-decrease))))) 24 | :init (setq default-text-scale-amount 5)) 25 | -------------------------------------------------------------------------------- /modules/theme/theme.el: -------------------------------------------------------------------------------- 1 | (defgroup my/theme-settings nil 2 | "My custom theme settings" 3 | :group 'my/custom-settings) 4 | (defcustom my/theme 'deeper-blue 5 | "Emacs Theme" 6 | :type 'symbol 7 | :group 'my/theme-settings) 8 | 9 | (defun my/theme-update (theme-fn) 10 | "Update the `my/theme` variable with the new theme and call THEME-FN." 11 | (let ((current-theme (car custom-enabled-themes))) 12 | (funcall theme-fn) 13 | (customize-set-variable 'my/theme (car custom-enabled-themes)) 14 | (customize-save-customized) 15 | (message "Theme changed to: %s" my/theme))) 16 | 17 | ;; Install themes directly from a git repository: 18 | ;;;NOTE: don't use deep-thought-theme it crashes Emacs 29.4!! 19 | ;;;Keeping this here as an example for loading a theme from git: 20 | ;; (use-package 21 | ;; deep-thought-theme 22 | ;; :straight 23 | ;; (deep-thought-theme :type git :repo "https://github.com/emacsfodder/emacs-deep-thought-theme.git")) 24 | (use-package solaire-mode :init (solaire-global-mode +1)) 25 | (use-package theme-looper 26 | :general 27 | ("C-" (lambda () (interactive) (my/theme-update 'theme-looper-enable-previous-theme))) 28 | ("C-" (lambda () (interactive) (my/theme-update 'theme-looper-enable-next-theme)))) 29 | 30 | (load-theme my/theme t) 31 | -------------------------------------------------------------------------------- /modules/treesit/treesit.el: -------------------------------------------------------------------------------- 1 | (use-package treesit-auto 2 | :custom 3 | (treesit-auto-langs '(awk bash bibtex blueprint c c-sharp 4 | clojure cmake commonlisp cpp css dart dockerfile elixir glsl go 5 | gomod heex html janet java javascript json julia kotlin latex 6 | lua magik make markdown nix nu org perl proto r ruby 7 | scala sql surface toml tsx typescript typst verilog vhdl vue 8 | wast wat wgsl yaml)) 9 | (treesit-auto-install 'prompt) 10 | :config 11 | (treesit-auto-add-to-auto-mode-alist 'all) 12 | (global-treesit-auto-mode)) 13 | 14 | (use-package treesit-jump 15 | :straight (:host github :repo "dmille56/treesit-jump" :files ("*.el" "treesit-queries")) 16 | :config 17 | ;; Optional: add some queries to filter out of results (since they can be too cluttered sometimes) 18 | ;;(setq treesit-jump-queries-filter-list '("inner" "test" "param")) 19 | -------------------------------------------------------------------------------- /modules/vterm/vterm.el: -------------------------------------------------------------------------------- 1 | ;; vterm (terminal emulator) :: 2 | ;; https://github.com/akermu/emacs-libvterm 3 | ;; Configure BASH to work with vterm: 4 | ;; https://github.com/akermu/emacs-libvterm#vterm-clear-scrollback 5 | (use-package 6 | vterm 7 | :custom (vterm-always-compile-module t) 8 | :general ("C-c t" 'my/vterm-toggle) 9 | :config (define-key vterm-mode-map (kbd "") nil) 10 | :hook ((vterm-mode . (lambda () (setq-local show-trailing-whitespace nil)))) 11 | :init 12 | ;; shell-pop for vterm :: https://github.com/jixiuf/vterm-toggle 13 | (use-package vterm-toggle) 14 | (defun my/vterm-toggle (&optional args) 15 | "Customized vterm-toggle wrapper- this fixes the universal 16 | argument (C-u) to always create a new terminal" 17 | (interactive "P") 18 | (if (not 19 | (or (derived-mode-p 'vterm-mode) 20 | (and (vterm-toggle--get-window) 21 | vterm-toggle-hide-method))) 22 | (if (equal current-prefix-arg '(4)) 23 | (vterm-toggle--new args) 24 | (vterm-toggle args)) 25 | (vterm-toggle args)))) 26 | -------------------------------------------------------------------------------- /modules/which-key/which-key.el: -------------------------------------------------------------------------------- 1 | ;; which-key (shows keyboard shortcut completions) :: https://github.com/justbur/emacs-which-key 2 | (use-package which-key :config (which-key-mode)) 3 | -------------------------------------------------------------------------------- /theme/emacs.theme: -------------------------------------------------------------------------------- 1 | #+HTML_HEAD: 2 | -------------------------------------------------------------------------------- /theme/icon/emacs.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EnigmaCurry/emacs/0fff807c42c527e3ecc5dfadd3662eff7cccc643/theme/icon/emacs.ico -------------------------------------------------------------------------------- /theme/simple_dark.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | margin: 0; 3 | padding: 0; 4 | min-height: 100vh; 5 | } 6 | body { 7 | background: #121212; 8 | color: #e0e0e0; 9 | font-family: "Bitstream Vera Sans",Verdana,sans-serif; 10 | display: flex; 11 | flex-direction: column; 12 | max-width: 90em; 13 | justify-content: center; 14 | margin:0 auto; 15 | } 16 | 17 | code { 18 | color: #ffd269; 19 | font-weight: bold; 20 | font-size: 1.5em; 21 | margin: 0 0.25em 0 0.25em; 22 | } 23 | 24 | div#content { 25 | border: 1px solid #666; 26 | background: #1e1e1e; 27 | padding: 2em; 28 | max-width: none; 29 | margin: 0; 30 | margin-bottom: auto; 31 | } 32 | 33 | a { 34 | color: #62afff; 35 | text-decoration: none; 36 | padding: 1px 37 | } 38 | 39 | a:hover { 40 | color: #ff5370 41 | } 42 | 43 | #table-of-contents { 44 | margin: 1em 0; 45 | padding: .1em 46 | } 47 | 48 | div#content div#org-div-home-and-up { 49 | background: #001323; 50 | color: #fff 51 | } 52 | 53 | div#org-div-home-and-up a:link,div#org-div-home-and-up a:visited { 54 | color: #fff; 55 | background: #001323 56 | } 57 | 58 | div#org-div-home-and-up a:hover { 59 | color: #ff5370 60 | } 61 | 62 | div.title { 63 | margin: -1em -1em 0; 64 | font-size: 200%; 65 | font-weight: bold; 66 | background: #001323; 67 | color: #fff; 68 | padding: .75em 1em; 69 | font-family: "BitStream Vera Sans",Verdana; 70 | letter-spacing: .1em 71 | } 72 | 73 | h1 { 74 | background: #001323; 75 | color: #fff; 76 | font-size: 200%; 77 | font-weight: bold; 78 | letter-spacing: .1em; 79 | margin: -1em -1em .2em; 80 | padding: .75em 1em 81 | } 82 | 83 | h2 { 84 | font-size: 180%; 85 | border-bottom: 1px solid #555; 86 | padding: .2em 87 | } 88 | 89 | h3,h4 { 90 | font-size: 120%; 91 | border-bottom: 1px solid #444 92 | } 93 | 94 | tt { 95 | color: #39f 96 | } 97 | 98 | .verbatim { 99 | margin: .5em 0 100 | } 101 | 102 | pre.src-shell { 103 | background: #0f1015; 104 | } 105 | 106 | pre.src-example { 107 | background: #282928 !important; 108 | } 109 | 110 | pre { 111 | font-weight: bolder; 112 | border: none; 113 | padding: 1em; 114 | color: #e0e0e0; 115 | margin: 1em 0 1em 0; 116 | padding: 5pt; 117 | color: #e0e0e0; 118 | font-family: courier,monospace; 119 | font-size: 0.8em; 120 | background: #181f29; 121 | max-width: 90.5em; 122 | border-bottom: 2px solid #573b3b; 123 | } 124 | 125 | .verbatim-caption { 126 | border: 1px solid #555; 127 | background: #222; 128 | display: block; 129 | font-size: 80%; 130 | padding: .2em 131 | } 132 | 133 | div#postamble { 134 | text-align: left; 135 | color: #999; 136 | font-size: 80%; 137 | padding: 0; 138 | margin: 0 139 | } 140 | 141 | div#postamble a { 142 | color: #62afff 143 | } 144 | 145 | div#postamble a:hover { 146 | color: #ff5370 147 | } 148 | 149 | table { 150 | font-size: 100%; 151 | border-collapse: collapse; 152 | margin: .5em 0; 153 | color: #e0e0e0 154 | } 155 | 156 | th,td { 157 | border: 1px solid #555; 158 | padding: .3em; 159 | margin: 2px 160 | } 161 | 162 | th { 163 | background: #333 164 | } 165 | 166 | span.underline { 167 | text-decoration: underline 168 | } 169 | 170 | .fixme { 171 | background: #ff9800; 172 | font-weight: bold 173 | } 174 | 175 | .ra { 176 | text-align: right 177 | } 178 | 179 | .sidebar { 180 | float: right; 181 | width: 25em; 182 | background-color: #6a1b9a; 183 | color: #fff; 184 | margin: 2em -2em 2em 2em; 185 | padding: 1em 186 | } 187 | 188 | .sidebar a { 189 | border: none 190 | } 191 | 192 | .sidebar a:link { 193 | color: #80deea 194 | } 195 | 196 | .sidebar a:visited { 197 | color: #26c6da 198 | } 199 | 200 | .sidebar a:hover { 201 | color: #ffcc80 202 | } 203 | 204 | .sidebar a:active { 205 | color: #ff5370 206 | } 207 | 208 | .title { 209 | text-align: center 210 | } 211 | 212 | .todo { 213 | color: #f44336 214 | } 215 | 216 | .done { 217 | color: #4caf50 218 | } 219 | 220 | .timestamp { 221 | color: #9e9e9e 222 | } 223 | 224 | .timestamp-kwd { 225 | color: #f48fb1 226 | } 227 | 228 | .tag { 229 | background-color: #1e88e5; 230 | font-weight: normal 231 | } 232 | 233 | .target { 234 | background-color: #8e24aa 235 | } 236 | 237 | pre.src:before { 238 | margin-right: 0.5em; 239 | } 240 | 241 | .org-ul li { 242 | padding-top: 0.5em; 243 | } 244 | 245 | details { 246 | margin: 2em; 247 | } 248 | 249 | .code-block-container { 250 | border-radius: 5px; 251 | overflow: visible; 252 | margin-bottom: 1em; 253 | box-shadow: 0 1px 3px rgba(0,0,0,0.1); 254 | max-width: 80em; 255 | } 256 | 257 | .code-block-header { 258 | background: #0d0d0d; 259 | border-bottom: 2px solid #573b3b; 260 | padding: 0.1em 1em 0.2em 0.5em; 261 | font-family: sans-serif; 262 | font-weight: bold; 263 | font-size: 0.9em; 264 | max-width: 80em; 265 | } 266 | 267 | .code-block-header.shell { 268 | color: #27d75b; 269 | } 270 | 271 | .code-block-header.lang { 272 | color: #606c71; 273 | } 274 | 275 | .code-block-container pre { 276 | margin: 0; 277 | } 278 | 279 | span.filename { 280 | font-family: monospace; 281 | font-size: 2em; 282 | margin-left: 0.5em; 283 | } 284 | 285 | span.org-parameter { 286 | background-color: #202020; 287 | padding: 0 0.5em; 288 | border-radius: 5px; 289 | font-size: 1.1em; 290 | } 291 | 292 | @media screen and (max-width:768px) { 293 | div#content { 294 | padding: 0 0.5em 0.5em 0.5em; 295 | h1.title{margin-top: 0em; 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /theme/simple_dark.theme: -------------------------------------------------------------------------------- 1 | #+HTML_HEAD: 249 | --------------------------------------------------------------------------------