Remix.run Logo
▲ knome 4 hours ago

you can replace or wrap arbitrary functions or update values freely in emacs. most of the editor is written in elisp. only the primitives are in c.

you can write (arbitrary (lisp)) and then just put the cursor after the end parenthesis and hit `Ctrl-x Ctrl-e` to evaluate it. It works just like you had typed out something in a python repl, only you can inspect, add, or update anything inside of your running copy of emacs.

As an example, I've had a chunk in my ~/.emacs for 15+ years that rewrites a few builtin functions to prefix all of the backup files emacs makes with a `.` because I don't like to see them in `ls` listings but still want them local to where they were made should I want to diff them against the current version. (the default is just a ~ suffix, and there's a common directory relocation many people use to pile them all in a backups directory somewhere)

As another, I wanted to be able to punch a button and drop the current datetime into a file, for files where I keep records and the like, so I added this:

    (defun my-date-insert ()
      (interactive)
      (insert (substring (shell-command-to-string "date") 0 -1 ))
      )
    
    (global-set-key [f9] 'my-date-insert)
Albeit, you needn't shell out to get a date in emacs, I dropped in in their years ago on a whim and just used what I knew at that time to toss it together.
▲a_e_k 2 hours ago | parent [-]

`(insert (format-time-string "%c"))` should do the trick, though you might need to change the format string to taste.