help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is Emacs very alive, active and improving?


From: Emanuel Berg
Subject: Re: Is Emacs very alive, active and improving?
Date: Fri, 30 Aug 2013 04:22:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Jorge <1gato0a@gmail.com> writes:

> I already use it, to edit LaTeX, configuration files, general
> text files (I should learn org mode to organize my text files),
> C++ and Bash source code, and compose emails.

(Warning. Long post. Don't be in a rush to read it.)

That sounds great!

If you do lots of configuration, like me, you'll notice that it is
a circus of the same files being edited, over and over. I found
this help me a lot - you may use another keystroke than C-j,
though J, K, L, and ; on the right hand, as requiring no reaching
whatsoever, will make for ultra fast transitions.

Note that the register names are mnemonic - 'a' for "aptitude",
etc. Also, the shortcuts are case sensitive, so there are quite a
lot of them, for lots of configuration. Last, note how to get
superuser access to files not in your PATH - namely, once set up,
by using the C-j IF exactly the same way :)

(global-set-key (kbd "C-j") 'jump-to-register)

(set-register ?a (cons 'file "/sudo::/etc/apt/sources.list"))
(set-register ?C (cons 'file "/sudo::/etc/default/console-setup"))
(set-register ?D (cons 'file "~/.emacs-man"))
(set-register ?d (cons 'file "~/.emacs-dired"))
(set-register ?K (cons 'file "/sudo::/etc/console-setup/remap.inc"))
(set-register ?k (cons 'file "/sudo::/etc/default/keyboard"))
; etc. etc;
(set-register ?x (cons 'file "~/.xinitrc"))
(set-register ?X (cons 'file "~/.Xresources"))
(set-register ?Z (cons 'file "~/.zprofile"))
(set-register ?z (cons 'file "~/.zshrc"))

Another great function for configuration, that I did in
collaboration with a guy here on GEH, is su-edit:

(defun su-edit ()
  "Edit the current buffer file as superuser."
  (interactive)
  (let ((window-start (window-start))
        (point        (point))
        (mark (if mark-active (region-beginning) nil)) )
    (find-alternate-file (format "/sudo::%s" (buffer-file-name)))
    (if mark (set-mark mark))
    (goto-char point)
    (set-window-start nil window-start) ; nil - the selected window
    ))

It even keeps the region - but for some reason, it gets
invisible...

Last, often in documentation, in the man pages, or on the web (if
you use W3M), you find paths and file names - like, "Configure
this /important/file to get a gorgeous interface", then, simply
place point at the beginning of the path, and use

(defun goto-file ()
  (interactive)
  (let*((file (thing-at-point 'filename))
        (in-home (string= "~" (car (split-string file "/"))))
        (final-file (if in-home file
                      (format "%s%s" "/sudo::" file) )))
    (find-file final-file) ))

To make config files more pleasant to watch when editing, you may
use any of two different methods to the buffers in a certain modes
- it is not so picky what mode it is, actually, as long as you get
highlighting (and not too unorthodox shortcuts, shadowing those
you are used to). The methods are - either by filename extension
(e.g., the "txt" in diary.txt), *or* by a comment, at the top of
the file (a hashbang - sort of).

(add-to-list 'auto-mode-alist  '("\\.inc\\'" . conf-unix-mode))
(add-to-list 'magic-mode-alist '("# conf"    . conf-mode))

There you have some new toys to try out :)

> Currently I use compose emails in Emacs and copy/paste them into
> gmail.  Maybe in the future I will configure Emacs as a proper
> mil client.

I did the same when I was active on the Linux/Unix Q&A site. It
worked for a long time but I stopped, it was just to boring, no
matter how many shorthands I set up (like Emacs always to a
particular file, etc.). To find a "proper mail client" in Emacs
isn't the easiest of tasks, I'm afraid.

The send part - with the Message-mode - try it with `C-x m' just
to feel its power - is the best part. I made it even better, if I
may, by writing a function that lets you iterate the headers with
the TAB and backtab keys, that you may find here [1] - along with
this little darling, that'll save all outgoing mails:

(defun save-sent-mail ()
  "Save sent messages."
  (write-file
    (format-time-string "~/Mail/sent/%Y-%m-%d_%T.m") nil) )
(add-hook 'message-sent-hook 'save-sent-mail)

Also, a system for aliases, as well as a signature (in a file),
are features that are very handy and practical (and in particular
the aliases). I wrote about this at gnu.emacs.gnus, if you are on
that group.

*Reading* mail, though, is another ball game. Getting Gnus to do
it would probably be the best. Right now, I use rmail, and it
doesn't do HTML that well, there are no threads, and sometimes you
cannot quit it because the "wrong" message is highlighted. It
seems that case-sensitive search breaks rmail. Also, rmail saves
all mails in *one* huge file (called RMAIL), so you cannot get to
them by you precious batch CLI-tools. Apart from those minor
distractions, that are a-typical for Emacs, rmail is great, and
especially compared to the web-UIs everyone else uses for mail.

> I am a beginner; although I have been using Emacs for years, I
> have never learned all its power - I only read the tutorial and
> the beginning of the reference manual, I have much more to read.

While it is great that you read, perhaps it is time to grab the
bull by his horns, and twist his neck? Just do it. Instead of
reading tutorials, you can just observe - how does this work? do I
want it like this? if not, can I remedy it by setting some
variable, or even rewriting (part of) it myself? The most
important thing is not that you read one page or even one chapter
every day, the most important thing is that you are active with
what you do - and each day learn a new command, a new shortcut,
how two thing stick together, and so on. Do it every day for a
year, you'll have 365 new pieces of knowledge.

Good luck!

[1] http://user.it.uu.se/~embe8573/gnus/index.html

-- 
Emanuel Berg - programmer (hire me! CV below)
computer projects: http://user.it.uu.se/~embe8573
internet activity: http://home.student.uu.se/embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]