Live data from Hacker News

Ask HN: What's the weirdest/best thing you've done with Emacs?

news.ycombinator.com

11–20 of 44 posts

Re: Ask HN: What's the weirdest/best thing you've done with Emacs?

#12
I use an Emacs construct called an idle timer to maintain a file of (the start and end of) every interval 7 minutes long or longer during which I did not interact with Emacs, which enables me to figure out when I started or stopped some activity.

A typical use of the file is figuring out retroactively when I got out of bed even though I didn't make any record of the event at the time the event happened: specifically, I look in the file, see a interval of emacs-idleness 7 hours long, which information I combine with my memory that I used Emacs within minutes of getting out of bed.

The file would be even more useful if it pertained to all my interactions with the OS, not just interactions with Emacs, but that would prove much harder to implement particularly because I would need to implement anew every time I switch OSes. (I was using a different OS when I wrote the Emacs code described above than I am using now.)

The code has provided me much value relative to its implementation cost (time spent).

Re: Ask HN: What's the weirdest/best thing you've done with Emacs?

#14
The best thing in the last year was that I made a mode for my job. All of my work repos are under the same folder so the mode gets activated for any file under that folder.

It's small right now but has functionality like creating a new migration and switching to the new file. I also have yas-snippets for SQL tied to the mode. Using which-key helps me not have to remember all of the commands.

Re: Ask HN: What's the weirdest/best thing you've done with Emacs?

#15
post #5

The weirdest thing I have done in Emacs is using it to generate WAVE files, with a visual interface. The music loops, so you can keep playing with it. I've given talks about the package at !!Con 2021 and EmacsConf 2020. Info about this at https://zck.org/bangbangcon2021 . Video at https://www.youtube.com/watch?v=BeTDIrJeriI . Bonus: the presentation itself is done from within Emacs, in another library I wrote.

Awesome! It's actually would be nice to have something like a library of MIDI snippets that you can record and store under org-mode bullets, sort them by tags (mood, tempo, genre) and then quickly copy them into a DAW. It would give another dimension to musicians, not only they can store verbally formulated ideas about their music in form of notes, but actually have a library of materials they can use.

Re: Ask HN: What's the weirdest/best thing you've done with Emacs?

#16
I made a basic game engine for Emacs. https://github.com/accidentalrebel/emacs-game-engine

Has easy to use coordibate system for placing characters on screen, shape drawing, keyboard and mouse output, and audio.

Maybe not tbe greatest, but it is was the most fun I had.

Re: Ask HN: What's the weirdest/best thing you've done with Emacs?

#17
In the full scope of what it can do it's not very weird, but I'd say it's the best I've done so far... is write a book!

It's in draft 2 at the moment, having been printed out and manually edited over the last couple months.

The path there was enlightening. From multiple crashes per attempt to lines and lines of customization. From unexpected crashes and automagical recovery. I've come to love this little word processor cum operating system. I only wish I had found it decades ago when I had more time to pour into a hobby.

Re: Ask HN: What's the weirdest/best thing you've done with Emacs?

#18

Earlier quoted context omitted.

Hi thanks for your sharing your usage! I'm very interested in doing this. I tried to use a sqlite database (using dbrowser gui) to handle my resources for my researching. But I'm not a programmer so I struggled to learn SQL. Couple questions: How do you handle mistyping the wrong tag? Is there something you use that could lint mistakes? Is there a way to show all the tags that's available or you've used? Like greppin…

> Is there a way to show all the tags that's available or you've used? No. But I could implement that in a few minutes. I could search for "tags:" headers, add the trailing text items to a list, then call function delete-dups. Or I could use a pre-defined list of tags and have a function that lets me select from that. But this starts moving away from the "just a text file" thing, and I'd have to start creating my own…

Thanks for answering! I looked into everything you said and gained a lot of ideas from this.

For anyone who uses vim or anyone interested reading, because the setup is pretty simple, I managed to put together a similar setup in vim.

I'm using bookmarks.txt for web and files.txt for local files (I have a TON of pdfs, books, .md, .txt, .doc, etc. to cross reference).

For web I need to open urls with different profiles (firefox/opera/chrome).

  "Add chrome folder to env variables
  nnoremap j :silent execute "!chrome "
  "Add firefox folder to env variables
  nnoremap k :silent execute "!firefox "
For files I'm using cmd (windows) to open the files using the default applications under the cursor.

  "https://stackoverflow.com/questions/23316272/gvim-windows-7-netrw-open-url-under-text-cursor
  "https://vi.stackexchange.com/questions/26007/getting-gx-to-open-a-url
  "https://vi.stackexchange.com/questions/26052/select-word-under-cursor
  "https://stackoverflow.com/questions/21224865/what-does-the-number-1-in-the-shellescape-function-mean-in-vim
  nnoremap h :silent execute '!explorer ' . shellescape(expand(''), 1)
I picked FZF to find the files quickly in the terminal. Also using FZF Vim plugin to search tags in bookmarks.txt and files.txt. It has similar behavior to how you described swiper.

From https://github.com/junegunn/fzf/blob/master/README-VIM.md#ex..., I send the FZF buffer line results to the quickfix window so results persist and jump easily to each bookmark. Use :BLines, "tag1 tag2 keyword" or "tag: tag1 tag2", selects all results, then sends it to the quickfix results.

Didn't modify the code from the example at all:

  " An action can be a reference to a function that processes selected lines
  function! s:build_quickfix_list(lines)
    call setqflist(map(copy(a:lines), '{ "filename": v:val }'))
    copen
    cc
  endfunction
  
  let g:fzf_action = {
    \ 'ctrl-q': function('s:build_quickfix_list'),
    \ 'ctrl-t': 'tab split',
    \ 'ctrl-x': 'split',
    \ 'ctrl-v': 'vsplit' }
I would have liked to use the location list instead of the quickfix window. Unfortunately, I couldn't get the location list to work for the buffer lines results. Seems like it only works for file results. See: https://github.com/junegunn/fzf/issues/1885.

Using to open the quickfix window. Then using (next) and (previous) to jump to each results.

  command! -nargs=0 JojoToggleQuickFix if empty(filter(getwininfo(), "v:val.quickfix")) | copen | else | cclose | endif
  nnoremap  :JojoToggleQuickFix
  nnoremap  :cnext
  nnoremap  :cprevious
I type "bmk" and it will expand to the following snippet.

  title:
  link:
  tags:
  date: @2021-07-07
  description:
This is the abbreviation in vim.

  "Bookmark/File snippet
  iabbrev bmk title:
      \link:
      \tags:
      \date: =strftime("@%Y-%m-%d")
      \description:
I setup custom syntax highlighting (title:, link:, tags:, date:, description:, and tags) for .txt files in vim.

    title: "Pixologic ZBrush - YouTube" 
    tags: @youtube @zbrush @3d @modeling @learn 
    link: https://www.youtube.com/c/PixologicZBrush/videos
    description: Industry standard 3D sculpting application.

Also using AutoHotkey to open files in the clipboard:

  ;https://www.autohotkey.com/docs/misc/Clipboard.htm
  :R*:````q:: 
  run, "%Clipboard%"
  return
I'm using this when I'm outside of vim.

Re: Ask HN: What's the weirdest/best thing you've done with Emacs?

#19

Earlier quoted context omitted.

> Is there a way to show all the tags that's available or you've used? No. But I could implement that in a few minutes. I could search for "tags:" headers, add the trailing text items to a list, then call function delete-dups. Or I could use a pre-defined list of tags and have a function that lets me select from that. But this starts moving away from the "just a text file" thing, and I'd have to start creating my own…

Thanks for answering! I looked into everything you said and gained a lot of ideas from this. For anyone who uses vim or anyone interested reading, because the setup is pretty simple, I managed to put together a similar setup in vim. I'm using bookmarks.txt for web and files.txt for local files (I have a TON of pdfs, books, .md, .txt, .doc, etc. to cross reference). For web I need to open urls with different profiles…

Oh nice. I like the use of snippets with a date stamp.
Post reply on HN