I’ve reached a very nice resting point in the ongoing effort to develop a very useful, powerful, stable, and cool computer setup.
This started a while back when I built a computer. In particular, this computer. There are several advantages to building a computer. You can save money or get more bang for your buck even if you don’t pay less. On the saving money side, maybe you have components on hand that you don’t have to buy. I did, mainly mass storage. The case I had, thinking I’d save money there, ended up not working out. You get more bang for the buck because the parts you buy will be better than the ones in the equivilant off the line but cheaper computer, and you’ll have more control over what happens in future upgrades. Continue reading A really good computer setup→
Or, at least, I’m surprised that this earlier implemented solution has not been mentioned in all the discussion about NSA spying.
Richard Stallman invented an approach to obviating the NSA’s attempts to spy on email. He included it in emacs, the world’s greatest text editor. Here how it works, from the manual. The “M” is the “alt” key (for all practical purposes) and “M-x followed by a word implements the command attached to that word.
32.6 Mail Amusements
M-x spook adds a line of randomly chosen keywords to an outgoing mail message. The keywords are chosen from a list of words that suggest you are discussing something subversive.
The idea behind this feature is the suspicion that the NSA1 and other intelligence agencies snoop on all electronic mail messages that contain keywords suggesting they might find them interesting. (The agencies say that they don’t, but that’s what they would say.) The idea is that if lots of people add suspicious words to their messages, the agencies will get so busy with spurious input that they will have to give up reading it all. Whether or not this is true, it at least amuses some people.
You can use the fortune program to put a “fortune cookie” message into outgoing mail. To do this, add fortune-to-signature to mail-setup-hook:
(add-hook ‘mail-setup-hook ‘fortune-to-signature)
You will probably need to set the variable fortune-file before using this.
________________________
Footnotes
[1] The US National Security Agency.
That is from the current, on-line emacs manual but it also appears in my hard copy of the manual which I believe dates to the last quarter of the 20th century.
I just reconfigured my laptop with a new system (a form of Linux) and, almost as important, a new power brick. That second item may be more interesting than it sounds for some of you; I’ll write that up later. This change also meant trashing my emacs configuration file. I didn’t have to trash it, of course, but it made sense to do so. I don’t use my laptop in any way that requires that I pay attention to data saved on it. It is a data-free appliance. Sort of. Or, at least, if I took the hard drive out of it and put it in a blender, I would not lose anything important other than a blender which would surely break. In order to achieve this state, I manage certain data not by backing it up but by ignoring it. If I toss the hard drive and put in a new one and install a new system, my emacs configuration file(s) can be gotten off of another computer. Or, preferably, just recreated from scratch.
Why would I want to recreate my emacs configuration files from scratch? Because a) it is fun and b) with the newest version of emacs, a number of things that required excessive messing around with before have become normal. Thus, the configuration files are less cumbersome and easier to manage.
In case you are still reading this post about emacs (good for you!) but don’t know much about it let me explain a few things. If you are already an emacs expert, you may want to skip down to my .emacs file and get right into ridiculing it.
emacs is the best text editor in the world for a number of reasons, but mainly because pretty nearly everything is configurable, and it is very cleanly associated with a very powerful programming language that you can write programs in to make your emacs text editor do amazing things like manage your email, carry out sophisticated statistical analyses on data, make coffee, or stand in for an operating system. Or, you can do like I do; find where other people have written these things and graciously made them available for others to use.
But emacs also suffers from a logical conundrum I call The emacs Paradox. Here is how it goes:
emacs is wonderful because you can configure it any way you want.
emacs keybindings (what happens when you press certain keys) are the most efficient possible therefore you must not change emacs keybindings.
We know this is an interesting paradox because right after hearing all about how emacs keybindings are wonderful, the first thing you will be told to do if you read the introductory material on emacs is to swap the caps lock and control keys, and the second thing you will be told to do is to replace the alt key with any one of a number of alternatives “so you won’t have to squish up your fingers” while executing “meta” commands. This duality (’emacs is perfect ’emacs is flawed) is part of what makes emacs a religion.
Like this:
That’s the guy who invented emacs.
OK, back to the point. emacs out off the box is probably pefect for some people. emacs with two or three hundred lines of elisp code in various files, some compiled, is perfect for others. But I use emacs to write, not program, so my needs are met by the out of the box version with a hadnful of changes.
My emacs file is below, and it is annotated to make it clear what each step does. This is all hand-codedd. Many of these changes can be made by selecting configuration options from the emacs menu.
Included in the file are a few comments of possible additional changes I may or may not make. I’m agnostic as to whether these changes are worthwhile; I go back and forth. The comments are in there as reminders.
The file is called .emacs and resides in the home directory on a Linux computer with all the other “dot” files, which are by default hidden from view in many file managers (unless you specify otherwise).
And here is mine (UPDATED to make CUA work better within emacs and between apps:
;
;
; This is a text editing-focused .emacs file
; a ";" means "comment" if it is in the first position
;
;---Reload the .emacs file after messing with with alt-x reload-dotemacs
(defun reload-dotemacs()
"Reload .emacs file"
(interactive)
(load-file "~/.emacs"))
; do not display the annoying startup screen
(setq inhibit-splash-screen t)
; get rid of annoying box cursor
; replace it with a nice bar cursor
(set-default 'cursor-type 'bar)
; type face size needs to be bigger on this laptop
; number (190)/10 = point size
(set-face-attribute 'default nil :height 190)
; scroll bar on right where all other scroll bars
; in the universe ever are
(set-scroll-bar-mode 'right)
; make Visual Line Mode work in text mode all the time
; (this means, make the text wrap as in a normal
; text editor)
(setq text-mode t)
(global-visual-line-mode 1)
(cua-mode t)
;
; Make sure ctrl-a selects all
;
(global-set-key (kbd "C-a") 'mark-whole-buffer)
;
;
; turn automatic spell checking on more or less universally
(defun turn-spell-checking-on ()
"Turn flyspell-mode on."
(flyspell-mode 1)
)
(add-hook 'text-mode-hook 'turn-spell-checking-on)
; turn on "CUA mode" ... so control -c, -v, -x, -z and
; a few other things work as they do in virtually all
; other software ever
(setq cua-auto-tabify-rectangles nil) ;; Don't tabify after rectangle commands
(transient-mark-mode 1) ;; No region when it is not highlighted
(setq cua-keep-region-after-copy t) ;; Standard Windows behaviour
; Make the keys work even if CUA does not:
(global-set-key (kbd "C-c") 'copy)
(global-set-key (kbd "C-v") 'paste)
; Make emacs use the system clipboard even if CUA does not:
(setq x-select-enable-clipboard t)
; associations
; add later some minor modes for certain kinds of files
;
; macros
; add later some handy markdown and html macros and functions
;
; make ctrl f cause forward "search"
(global-set-key (kbd "C-f") 'isearch-forward)
; make ctrl s save the current document
(global-set-key (kbd "C-s") 'save-buffer)
; some other time make the escape key stop commands in process
;
; Don't make the files with the #'s in the names
; a default emacs behavior we don't want
(setq auto-save-default nil) ; stop creating those #auto-save# files
; make a hidden backup to a directory mirroring the full path
; of files edited
(defun my-backup-file-name (fpath)
"Return a new file path of a given file path.
If the new path's directories does not exist, create them."
(let* (
(backupRootDir "~/.emacs.d/emacs-backup/")
(filePath (replace-regexp-in-string "[A-Za-z]:" "" fpath )) ; remove Windows driver letter in path, e.g. “C:”
(backupFilePath (replace-regexp-in-string "//" "/" (concat backupRootDir filePath "~") ))
)
(make-directory (file-name-directory backupFilePath) (file-name-directory backupFilePath))
backupFilePath
)
)
(setq make-backup-file-name-function 'my-backup-file-name)
; make the titlebar (window frame top) show the name of the file in the buffer.
(setq frame-title-format "%b")
;
;
;
; Line by line scrolling. By default, Emacs scrolls off the visible buffer by several lines. This is annoying
; This causes the scroll set to be whatever you want, in this ase, 1
;
;
(setq scroll-step 1)
;
;
; also, make the middle mouse wheel scroll only one line at a time
;
;
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)))
;
; later:
;
; make home and end buttons work better
;
; figure out how to make emacs work better with markdown
;
; Tabs, fast tab switching
;
`M-x spook’ adds a line of randomly chosen keywords to an outgoing mail
message. The keywords are chosen from a list of words that suggest you
are discussing something subversive.
The idea behind this feature is the suspicion that the NSA(1) and
other intelligence agencies snoop on all electronic mail messages that
contain keywords suggesting they might find them interesting. (The
agencies say that they don’t, but that’s what they _would_ say.) The
idea is that if lots of people add suspicious words to their messages,
the agencies will get so busy with spurious input that they will have
to give up reading it all. Whether or not this is true, it at least
amuses some people.
You can use the `fortune’ program to put a “fortune cookie” message
into outgoing mail. To do this, add `fortune-to-signature’ to
`mail-setup-hook’:
(add-hook ‘mail-setup-hook ‘fortune-to-signature)
You will probably need to set the variable `fortune-file’ before using
this.
___________
Please send FSF & GNU inquiries to gnu@gnu.org. There are also other ways to contact the FSF.
Please send broken links and other corrections (or suggestions) to webmasters@gnu.org.
After a little messing around with interesting emacs goodies, we might as well get right on to the good stuff.
emacs uses a concept called “modes.” You’ll learn about that if you use emacs. For now, what you need to know is that there are “major modes” and “minor modes” and we’re only interested in major modes at this moment. There are several major modes that make emacs highly useful for specific purposes, and some of those modes are designed with writing in mind, such as the text-mode the outline-mode and what is known as muse-mode. But writers really want to use org-mode and not much else.