[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs keyboard command
From: |
Le |
Subject: |
Re: Emacs keyboard command |
Date: |
27 Jul 2006 22:29:17 -0700 |
User-agent: |
G2/0.2 |
B. T. Raven wrote:
> C-<backspace> if Backspace is Del. Also hold Ctl down while typing a-k
> will delete everything back to the read-only prompt.
I'm late to the discussion, but this seems to be what the OP wanted?
Insert into your init file or autoload as you see fit.
(eval-when-compile (require 'cl))
(defvar le::directory-sep-chars "/\\\\")
(defmacro Init-emacs-load (emacs-form &rest xemacs-forms)
"Expand to EMACS-FORM on Emacs, XEMACS-FORM on XEmacs."
(if (featurep 'xemacs)
(cons 'progn xemacs-forms)
emacs-form))
(defmacro Init-cond (&rest args)
"just like cond, except result of expansion is compiled."
(dolist (arg args)
(when (eval (car arg))
(return (cons 'progn (cdr arg))))))
(defun _le::kill-path-element (arg)
"kils arg number or path elements negative is backwards"
(let ((old-point (point))
skip-func
limit)
(if (< arg 0)
(setq skip-func 'skip-chars-backward
limit (Init-cond
((fboundp 'minibuffer-prompt-end)
(minibuffer-prompt-end))
(t
(point-min))))
(setq skip-func 'skip-chars-forward
limit (point-max)))
(setq arg (abs arg))
(dotimes (i arg)
(let ((old-point (point)))
(eval (list skip-func le::directory-sep-chars limit))
(eval (list skip-func (concat "^" le::directory-sep-chars)
limit))
(when (eq (point) old-point)
(return))))
(unless (eq (point) old-point)
(kill-region (point) old-point))))
;;;###autoload
(defun le::kill-path-element (arg)
(interactive "*p")
(_le::kill-path-element arg))
;;;###autoload
(defun le::backward-kill-path-element (arg)
(interactive "*p")
(_le::kill-path-element (- arg)))
(mapc
#'(lambda (map)
;; (define-key map [remap backward-kill-word]
'le::backward-kill-path-element)
;; (define-key map [remap kill-word] 'le::kill-path-element)
(substitute-key-definition 'backward-kill-word
'le::backward-kill-path-element map global-map)
(substitute-key-definition 'kill-word 'le::kill-path-element map
global-map))
(Init-xemacs-load
(list read-file-name-map
read-file-name-must-match-map)
(list minibuffer-local-filename-completion-map
minibuffer-local-must-match-filename-map
)))