Doom 3 Site 2 Code

0 views
Skip to first unread message

James Talbot

unread,
Aug 5, 2024, 2:35:02 PM8/5/24
to ciscedisho
Howcan I change formatter used for specific file type in doom-emacs format module?So far I've been happy with using mostly doom defaults and haven't gotten into writing custom configurations and seriously using Elisp, so I'm a bit lost.

I'm trying to use doom-emacs as an IDE for Laravel development and I'm running into problems with Blade files. The main one being wrong code auto formatting. Prettier run from the command line has no problem formating the files, but doom defaults do. Eg.:


The package behind the format module is format-all. Going down the rabbit hole, its method of determining the current buffer's language is delegated to language-id, which has a nice DSL for detecting web-mode peculiarities. Adding a entry for blade may cut it:


Doom has now switched from using format-all to the apheleia package to handle formatting, and prettier is already the default formatter for web-mode buffers, so for the purposes of this question it is only necessary to ensure that web-mode is enabled for *.blade.php files, see: how do I enable web-mode .blade.php files? for details in how to do that in case it is not already configured in Doom (which I think it is).


In my ongoing series of literate config files, I am now posting my Doom Emacs config. I switched to Doom from my hand-crafted Emacs config some time ago, and I have been really enjoying it. Hope you find it useful!


This file is written in literate programming style using org-mode. See init.el, packages.el and config.el for the generated files. You can see this in a nicer format on my blog post My Doom Emacs configuration, with commentary.


Note: a lot of manual configuration has been rendered moot by using Emacs Doom, which aggregates a well-maintained and organized collection of common configuration settings for performance optimization, package management, commonly used packages (e.g. Org) and much more.


All the config files are generated from this Org file, to try and make its meaning as clear as possible. All package! declarations are written to packages.el, all other LISP code is written to config.el.


We start by simply defining the standard headers used by the three files. These headers come from the initial files generated by doom install, and contain either some Emacs-LISP relevant indicators like lexical-binding, or instructions about the contents of the file.


Allow mixed fonts in a buffer. This is particularly useful for Org mode, so I can mix source and prose blocks in the same document. I also manually enable solaire-mode in Org mode as a workaround for font scaling not working properly.


I love the spacemacs-light theme, but for some reason, the transparent dashboard images showed up with a light tint, which I eventually tracked to the fact that Doom by default uses the font-lock-comment-face for the dashboard banner image, and this this face has a background color in Spacemacs-light. I redefine the doom-dashboard-banner face to use the default face, which fixes the problem. Another way to fix it (commented out below) is to disable the background tint color in the theme. While we are at it, I also fix doom-dashboard-loaded, which suffers from the same problem.


Doom Emacs has an extensive keybinding system, and most module functions are already bound. I modify some keybindings for simplicity of to match the muscle memory I have from my previous Emacs configuration.


Note: I do not use VI-style keybindings (which are the default for Doom) because I have decades of muscle memory with Emacs-style keybindings. You may need to adjust these if you want to use them.


Use counsel-buffer-or-recentf for C-x b. I like being able to see all recently opened files, instead of just the current ones. This makes it possible to use C-x b almost as a replacement for C-c C-f, for files that I edit often. Similarly, for switching between non-file buffers I use counsel-switch-buffer, mapped to C-x C-b.


The counsel-buffer-or-recentf function by default shows duplicated entries because it does not abbreviate the paths of the open buffers. The function below fixes this, I have submitted this change to the counsel library ( -abo/swiper/pull/2687), in the meantime I define it here and integrate it via advice-add.


The switch-buffer-functions package allows us to update the recentf buffer list as we switch between them, so that the list produced by counsel-buffer-or-recentf is shown in the order the buffers have been visited, rather than in the order they were opened. Thanks to @tau3000 for the tip.


One of the few things I missed in Emacs from vi was the % key, which jumps to the parenthesis, bracket or brace which matches the one below the cursor. This function implements this functionality, bound to the same key. Inspired by NavigatingParentheses, but modified to use smartparens instead of the default commands, and to work on brackets and braces.


Org mode has become my primary tool for writing, blogging, coding, presentations and more. I am duly impressed. I have been a fan of the idea of literate programming for many years, and I have tried other tools before (most notably noweb, which I used during grad school for homeworks and projects), but Org is the first tool I have encountered which makes it practical. Here are some of the resources I have found useful in learning it:


Enable Speed Keys, which allows quick single-key commands when the cursor is placed on a heading. Usually the cursor needs to be at the beginning of a headline line, but defining it with this function makes them active on any of the asterisks at the beginning of the line.


counsel-org-link uses org-id as its backend which generates IDs using UUIDs, and it uses the ID property to store them. I prefer using human-readable IDs stored in the CUSTOM_ID property of each heading, so we need to make some changes.


Second, I override counsel-org-link-action, which is the function that actually generates and inserts the link, with a custom function that computes and inserts human-readable CUSTOM_ID links. This is supported by a few auxiliary functions for generating and storing the CUSTOM_ID.


I use LeanPub for self-publishing my books. Fortunately, it is possible to export from org-mode to both LeanPub-flavored Markdown and Markua, so I can use Org for writing the text and simply export it in the correct format and structure needed by Leanpub.


ox-hugo is an awesome way to blog from org-mode. It makes it possible for posts in org-mode format to be kept separate, and it generates the Markdown files for Hugo. Hugo supports org files, but using ox-hugo has multiple advantages:


This function receives three arguments, and returns the org-mode code for a link to the Hammerspoon API documentation for the link module, optionally to a specific function. If desc is passed, it is used as the display text, otherwise section.function is used.


The first function is a modified version of the org-num--number-region function of the org-num package, but modified to only return the numbering of the innermost headline in which the cursor is currently placed.


Tangle-on-save has revolutionized my literate programming workflow. It automatically runs org-babel-tangle upon saving any org-mode buffer, which means the resulting files will be automatically kept up to date. For a while I did this by manually adding org-babel-tangle to the after-save hook in Org mode, but now I use the org-auto-tangle package, which does this asynchronously and selectively for each Org file where it is desired.


Some useful settings for LISP coding - smartparens-strict-mode to enforce parenthesis to match. I map M-( to enclose the next expression as in paredit using a custom function. Prefix argument can be used to indicate how many expressions to enclose instead of just 1. E.g. C-u 3 M-( will enclose the next 3 sexps.


I use 750words.com for recording some writing every day (1464-day streak as of this writing!). I wrote 750words-client to allow posting my words from the command line, and the code below integrates this into Emacs, so I can post text directly from the current buffer.


The classic 1993 video game Doom has had an amazing life over the last 30 years. Not only are there people still adding new levels via offical add-ons, but the modding community is going strong. For example, check out Beautiful Doom HD!


The other side of the Doom fandom lies in porting the game to all sorts of weird and unlikely screens. It has been ported to a pregnancy test, a graphical calculator, a MacBook Pro touch bar, and even on a tractor. Someone has even got Doom running inside of Doom itself, because why not.


In order to proceed, an element needs to be referenced on the page. This can either be an existing element or a brand new one can be created. For our website, a brand new section is built using JavaScript utilising document.createElement() commands and then prepended to the beginning of the body using Element.prepend().


Now that an element on the page is available, the Dosbox emulator can be initialised. To do this, see the link to the js-dos v6.22 examples below. However, the following key changes (highlighted) were made.


This new Custom HTML tag needs a trigger. The tag would need to be executed on one of the page load triggers, either DOM Ready at the earliest, or Window Loaded at the safest. This is to ensure that the page is ready to have its visible features changed.


Simply follow the instructions in setting up the Custom HTML tag. The example included will reverse any of the text in an element, but the contents of the runKonami() function can be changed to run any arbitrary JavaScript code.


In the course of game, players will encounter two Martian Buddy storage lockers. Players had to go to the Martian Buddy website to get the combination for the two Martian Buddy storage lockers.[1] In 2012, following the release of the BFG Edition, this code is written on the title of the message, since the Martian Buddy website has been taken down and replaced with a Store page for Bethesda Softworks. Both Martian Buddy storage lockers are the only two lockers in the game to have a code longer than 3 digits.

3a8082e126
Reply all
Reply to author
Forward
0 new messages