I don't think of Emacs as an IDE or even a programming environment unless I'm writing Lisp to automate Emacs. Instead, I consider Emacs to be a text editor with some useful extras.
Syntax highlighting (font-lock-mode) is a nice extra. It might seem strange that I consider syntax highlighting to be an extra. If you've used a text editor 40 years ago, you'll understand why -- text editors didn't have the feature. Syntax highlighting was the purview of the compiler tool. My first experience with syntax highlighting was with Borland Turbo Pascal; I used Borland Turbo C soon after. (I think Borland's Turbo Assembler, TASM, had the feature, too.)
According to packages-selected-packages, these are the programming
modes I have configured:
- basic-mode
- csv-mode
- gnuplot
- matlab-mode
- powershell
- python and python-mode
- Swift mode
I don't program in Swift. Perhaps the package is a dependency for another mode. Or maybe I was ambitious one day and thought I'd try another programming language.
Is csv a programming language? If you automate the generation of spreadsheets. it's nice to have some help. But to be honest, I've not used it very often.
Easy access to shell is another nice extra. I have two functions
to make use of it when I write batch files. They execute either the
current line (exeln) or the entire buffer
(shellfn) with some sort of shell command; they are shown
below. The Windows binary uses cmdproxy.exe from MinGW -- it works
out-of-the-box. But I use the Windows start program for shellfn
because it invokes the correct executable based on the file's
extension. Thus, Python runs a .py file; cmd, a .bat; Octave, a .m
file.
;; This is bound to C-c x ;; Many thanks to Sebastián Monía for suggesting many improvements (defun exeln (arg) "Execute current line as a shell command. With prefix ARG, run asynchronously." (interactive "P") (funcall (if arg #'async-shell-command #'shell-command) (thing-at-point 'line t))) ;; This is bound to C-c s (defun shellfn () "Invokes the shell using the current buffer file name as a parameter." (interactive) (shell-command (concat "start " (buffer-file-name))))
I've tried to use source blocks in Org, but I prefer putting each code snippet into its own dedicated file. Why? One reason is because I don't want the code to execute with org-mode active. Another reason is that indentation doesn't work properly. Switching modes fixes both issues, but it gets annoying very quickly. This is a topic for another post.
I look forward to seeing how other folks use Emacs for programming.
1 comment:
What do you mean when you say "don't want the code to execute with org-mode active"? Unless the source code is in Emacs Lisp whether or not org-mode is "active" (and I'm not sure what you mean by that) sounds irrelevant.
Post a Comment
Thank you for taking time to comment. Please note that comments may be deleted if they:
* Contain link(s) to a domain outside USA or Canada or to a commercial enterprise.
* Include non-English words or characters.
* Are irrelevant to the subject matter of the post.
For posts older than 14 days, comments are moderated and require approval.