Opening Unity Script Files in Emacs
I've recently embarked on a mission to fully integrate Emacs with my Unity game development environment. One feature that I wanted to have is the ability to open Unity scripts and text-based files in Emacs instead of MonoDevelop. This is an easy task for supported external editors but for those who aren't (Like Emacs), doing something like this is a bit tricky.
Setting emacsclient as the external editor works in opening the files but the line number is not passed at all (Or is not received by emacs. Seems to be a bug). This means that opening files in the Project Window works but you would not be able to to jump to lines that have errors from the Console. This, of course, is unacceptable.
I've tried a number of different solutions. A lot of them are hacky but clever. There was this one option of setting a Sublime Text …
Temp Solution For When Text Copying Does Not Work in Emacs Under Windows Subsytem for Linux
One of the problems I was having with my Emacs environment under WSL (Windows Subsystem for Linux, aka. Bash On Windows) is that I could not copy text from WSL Emacs to other Windows applications. Copy and pasting from Windows to Emacs works without any problems so it's weird it does not work the other way around.
I tried a lot of solutions from Google but none of them seem to work. There was an emacs package called simpleclip that worked but the results were not consistent.
I then realized that a temporary solution would be to make use of Windows' clip.exe command line utility which can bme seen below.
(defun arebel-set-clipboard-data (str-val)
"Puts text in Windows clipboard. Copying to Windows from WSL does
not work on my end so this one is a temporary solution.
This function is called from within the simpleclip package when copy
or bgcopy …
Converting org-journal entry to org-page post
I needed a way to minify JSON files from Emacs so I made the short function below.
(defun arebel-minify-buffer-contents()
"Minifies the buffer contents by removing whitespaces."
(interactive)
(delete-whitespace-rectangle (point-min) (point-max))
(mark-whole-buffer)
(goto-char (point-min))
(while (search-forward "\n" nil t) (replace-match "" nil t)))
The function is very simple. First it deletes the whitespaces for the whole current buffer then removes every newline.
This effectively turns this:
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
To this:
{"glossary": {"title": "example glossary","GlossDiv": {"title": "S","GlossList": {"GlossEntry": {"ID": "SGML","SortAs": "SGML","GlossTerm": "Standard Generalized Markup Language","Acronym": "SGML","Abbrev": "ISO 8879:1986","GlossDef": {"para": "A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso": ["GML", "XML"]},"GlossSee": "markup …