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

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

RE: [h-e-w] Highlighting


From: Peter Milliken
Subject: RE: [h-e-w] Highlighting
Date: Fri, 21 Feb 2003 07:29:22 +1100

Scott,

Probably the best approach is to create a "defadvice" for all your common
editing modes - this is a handy approach to the problem because once you
have set your defadvice you can then add other common minor modes as it
takes your fancy. I use the following in my .emacs for all of my major modes
(only ada-mode shown here though):

(defun turn-on-useful-minor-modes ()
  "Does the work of turning on minor modes that I find useful when coding."
  (progn
    ;; Turns on fill-mode. The minor mode enables and disables fill-mode as
the
    ;; "face" changes i.e. when the "face" is a comment then fill-mode is
active
    ;; any other time it is inactive
    (tmmofl-mode)
    (ishl-mode)
    ;; Make sure that the fill column is set to the correct value.
    (set-fill-column 80)
    ;; Turn on ELSE for the buffer as well. 
    (else-mode)
    (show-paren-mode)
    )
  )

(defadvice ada-mode (after minor-modes-for-ada activate compile)
  "Turn on a default set of minor modes when using ada-mode."
  (turn-on-useful-minor-modes)
  )

This basically wraps an elisp defun of my choice around the call to invoke
ada-mode. Thus when I load a file that my auto-mode-alist has determined
should be in ada-mode, I get all of the minor modes etc that are invoked in
'turn-on-useful-minor-modes :-)

Read about defadvice in the Elisp manual - it is very handy :-)

Hope this helps,
Peter


-----Original Message-----
From: Scott Purcell [mailto:address@hidden
Sent: Friday, February 21, 2003 6:52 AM
To: address@hidden
Subject: [h-e-w] Highlighting


Hello,
I am trying to get emacs to highlight areas when I am using the editor via
the keyboard.  Firstly, I have a _emacs file (I am on a pc) and it works.
And when I mouse and highlight some text, it shows up highlighted.

But I try to never use a mouse, and when I use the  ctl [spacebar] ctr e
(which marks a line) it does not get highlighted. How do I turn on that
function. (I know I can turn it on each time using Emacs/help/options
(Transient/Mark Mode) on the menu, but I am getting of tired of turning that
on each time I launch emacs.

Thanks,
Scott


;; turn on pc type settings (home/end, shift cursor keys etc.)
(pc-selection-mode)

;;{{{ SET auto-mode-alist
(setq auto-mode-alist
      '(("\\.[Cc][Oo][Mm]\\'" . text-mode)
        ("\\.bat\\'" . bat-generic-mode)
        ("\\.inf\\'" . inf-generic-mode)
        ("\\.rc\\'" . rc-generic-mode)
        ("\\.reg\\'" . reg-generic-mode)

        ("\\.te?xt\\'" . text-mode)
        ("\\.c\\'" . c-mode)
        ("\\.h\\'" . c++-mode)
        ("\\.tex$" . LaTeX-mode)))

;;}}}



;; highlight the marked region
(transient-mark-mode t)
(setq transient-mark-mode t)
(global-font-lock-mode t)
(setq font-lock-maximum-mode t)

;; highlight matching paren
(show-paren-mode 1)

;; set tab width
(setq default-tab-width 4)
(setq-default indent-tabs-mode nil)   ;; use spaces not real tabs
(setq-default perl-tab-to-comment t)  ;; in perl TAB indents lines or
comments

;; show current line and column number in status bar
(setq line-number-display-limit 99999) 
(setq line-number-mode t) 
(setq column-number-mode t) 

;; make it quiet - bell just flashes the screen
(setq visible-bell t)

;; map M-g to goto-line
(global-set-key "\M-g" 'goto-line)

;; remember to remove extra ^M from DOS command output
(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)


;; Turn on font-lock stuff for colour syntax highlighting
;; Set up some colours ...
;;
(cond ((fboundp 'global-font-lock-mode)
       ;; Customize the face attributes
       (setq font-lock-face-attributes
             ;; Symbol-for-Face Foreground Background Bold Italic Underline
             '((font-lock-comment-face       "DarkGreen" "gray95")
                   (font-lock-constant-face      "Red" "white" 1)
               (font-lock-function-name-face "Blue")
               (font-lock-keyword-face       "Navy" "white" 1)
               (font-lock-reference-face     "Purple")
               (font-lock-string-face        "Red")
               (font-lock-type-face          "Black")
               (font-lock-variable-name-face "Black" "white" 1)

               ))
       ;; Load the font-lock package.
       (require 'font-lock)
       ;; Maximum colors
       (setq font-lock-maximum-decoration t)
       ;; Turn on font-lock in all modes that support it
       (global-font-lock-mode t)))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; perl debugger support

;;;  Have to fix up compilation mode for perl
(require 'compile)

;;  Add the regex for looking for perl compile errors
(defvar perl-compilation-error-regexp-alist 
  ;; This looks like a paranoiac regexp: could anybody find a better one?
  '(("^[^\n]* \\(file\\|at\\) \\([^ \t\n]+\\) [^\n]*line \\([0-9]+\\)[\\.,
\n]"
     2 3))
  "Alist that specifies how to match errors in perl output.")
(setq compilation-error-regexp-alist
      (append compilation-error-regexp-alist
              perl-compilation-error-regexp-alist))

;;  Make compilation mode think that gud buffers are OK for error parsing.
(defsubst compilation-buffer-p (buffer)
  (save-excursion
    (set-buffer buffer)
    (or (or compilation-minor-mode (eq major-mode 'compilation-mode))
        (eq major-mode 'gud-mode))))

;;;  Have to fix up gud mode for perl
(require 'gud)

;;  Re-define gud-perldb-massage-args to handle variable perl flags
(defvar gud-perldb-interp-flags "-dw"
  "The flags to pass to the perl interpreter when running a debug session.")
(defun gud-perldb-massage-args (file args)
  (cons gud-perldb-interp-flags (cons (car args) (cons "-emacs" (cdr
args)))))
;;(cons gud-perldb-interp-flags (cons (car args) (cons "" (cdr args)))))


;; Fix for perldb - make default reasonable and allow no-prompt option
(defun better-perldb (&optional arg)
  "Runs perldb with better handling of default command string.
With arg true, doesn't prompt for new command, uses last one."
  (interactive)
  (if (not (null arg))
      (perldb (car gud-perldb-history))
      (perldb (read-from-minibuffer
               "Run perldb (like this): "
               (if (and (consp gud-perldb-history)
                        (string-match
                         (concat "^ *[^ ]+ +" (buffer-file-name))
                         (car gud-perldb-history)))
                   (car gud-perldb-history)
                   (concat "perl " (buffer-file-name)))
               nil nil
               '(gud-perldb-history . 1)))))

;;  Add functions that do compilation error matching using compilation mode,
;;  then switch back when done.  (C-x` for next-error, C-xx to exit)
(defun perl-next-error ()
  "Moves to the next perl error from the last perldb run."
  (interactive)
  (next-error))
(defun perl-next-error-start ()
  "Moves to the next perl error from the last perldb run."
  (interactive)
  (compilation-minor-mode)
  (define-key (current-local-map) "\C-x`" 'perl-next-error)
  (define-key (current-local-map) "\C-xx" 'perl-next-error-end)
  (next-error))
(defun perl-next-error-end ()
  "Ends compilation mode for finding perl errors and returns to perldb
mode."
  (interactive)
  (set-buffer (compilation-find-buffer))
  (compilation-minor-mode))
(defun perldb-compilation-preferences ()
  (define-key (current-local-map) "\C-x`" 'perl-next-error-start))
(add-hook 'perldb-mode-hook '(lambda () (perldb-compilation-preferences)))
;;(custom-set-faces '(default ((t (:background "sky blue"))) t))



Warning:  Copyright ResMed.  Where the contents of this email and/or attachment 
includes materials prepared by ResMed, the use of those materials is subject 
exclusively to the conditions of engagement between ResMed and the intended 
recipient.

This communication is confidential and may contain legally privileged 
information. By the use of email over the Internet or other communication 
systems, ResMed is not waiving either confidentiality of, or legal privilege 
in,the content of the email and of any attachments.
If the recipient of this message is not the intended addressee, please call 
ResMed immediately on  +61 2 9886 5000 Sydney, Australia.





reply via email to

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