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

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

Re: Sanest way to make emacs behave on a Solaris OS


From: Emanuel Berg
Subject: Re: Sanest way to make emacs behave on a Solaris OS
Date: Thu, 08 Aug 2013 17:36:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

> Another solution ...

It wasn't a good idea to call the files (for example) .xterm,
because that is the norm of config files (that are not related to
Xresouces: for example, couldn't be used for Emacs).

So invented the .xr extension for this purpose.

Some "extra material" - haven't tested that much, but seems to
work. Comments are always welcome.

;;; Xresources etc.
(add-to-list 'magic-mode-alist
             '("! conf-xd" . conf-xdefaults-mode))
(add-to-list 'auto-mode-alist
             '("\\.xr\\'"  . conf-xdefaults-mode))

;; get resource file by tool name
(defun x-conf (tool)
  (interactive "s tool: ")
  (find-file (format "~/.%s.xr" tool)) )

;; get resource file by placing the cursor at an #include line;
;;   haven't tested (for that), but could be useful
;;   for C and C++ with some adjustments
(defun follow-x-conf ()
  (interactive)
  (save-excursion ; I was hesitant to add this,
                  ; because `goto-conf' does it, but
                  ; for the possibility of direct invocation
    (beginning-of-line)
    (forward-word 1) ; get by #include
    (forward-char 2) ; get by WS and DQM
    (find-file (thing-at-point 'filename)) ))

;; umbrella function that will invoke one of the above
(defun goto-conf ()
  (interactive)
  (save-excursion
    (beginning-of-line)
    (if (< (point) (point-max)) ; not to break on EOB
                                ; (is there such a predicate?)
        (progn
          (forward-char 1) ; get by hash;
          (if (string= (thing-at-point 'word) "include")
              (follow-x-conf)
            (call-interactively 'x-conf) ))
      (call-interactively 'x-conf) )))

;; shortcut as you see fit
; (define-key (current-global-map) (kbd "...") 'goto-conf)

;; as always, my method to get to config files
;; (not just X config files), fast:
; (global-set-key (kbd "C-j") 'jump-to-register)
; (set-register ?X (cons 'file "~/.Xresources"))

-- 
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]