unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Java mixed case deletion
@ 2004-10-26 17:21 Mahesh Padmanabhan
  2004-10-26 19:23 ` Benjamin Rutt
  0 siblings, 1 reply; 4+ messages in thread
From: Mahesh Padmanabhan @ 2004-10-26 17:21 UTC (permalink / raw)


Hi,

I currently have the following set up as part of my java mode hook:

(add-hook 'java-mode-hook
           (function (lambda ()
                       (c-set-style              "stroustrup")
                       (c-set-offset 'inline-open 0)
                       (define-key java-mode-map  "\C-c\C-d" 'insert-date)
                       (make-local-variable      'comment-multi-line)
                       (define-key java-mode-map
                         [C-right] 'c-forward-into-nomenclature)
                       (define-key java-mode-map
                         [C-left] 'c-backward-into-nomenclature)
                       (setq comment-multi-line  t))))

The functions c-forward-into-nomenclature and 
c-backward-into-nomenclature take care of negotiating mixed case words 
but i could not find anything that allows me to delete while keeping 
mixed case in mind.

For example - if there is a word like this: SomeClass then a backward 
delete word deletes the whole word. What I want is to delete just Class 
in SomeClass.

Is it possible?

Thanks,
Mahesh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Java mixed case deletion
  2004-10-26 17:21 Java mixed case deletion Mahesh Padmanabhan
@ 2004-10-26 19:23 ` Benjamin Rutt
  2004-10-26 19:52   ` Mahesh Padmanabhan
  2004-10-26 22:41   ` Kevin Rodgers
  0 siblings, 2 replies; 4+ messages in thread
From: Benjamin Rutt @ 2004-10-26 19:23 UTC (permalink / raw)


Mahesh Padmanabhan <mahesh@privacy.net> writes:

> The functions c-forward-into-nomenclature and
> c-backward-into-nomenclature take care of negotiating mixed case words
> but i could not find anything that allows me to delete while keeping
> mixed case in mind.
>
> For example - if there is a word like this: SomeClass then a backward
> delete word deletes the whole word. What I want is to delete just
> Class in SomeClass.

(defun my-c-kill-forward-into-nomenclature (&optional arg)
  "Kill forward to the end of a nomenclature section or word.  With
arg, do it arg times."
  (interactive "p")
  (save-excursion
    (set-mark (point))
    (c-forward-into-nomenclature arg)
    (kill-region (mark) (point))))

(defun my-c-kill-backward-into-nomenclature (&optional arg)
  "Kill backward to the beginning of a nomenclature section or word.
th arg, do it arg times."
  (interactive "p")
  (save-excursion
    (set-mark (point))
    (c-backward-into-nomenclature arg)
    (kill-region (mark) (point))))

Add those to your keys of choice in the hook and you're all set.  I
use 

  (local-set-key [(control backspace)] 'my-c-kill-backward-into-nomenclature)
  (local-set-key [(meta d)] 'my-c-kill-forward-into-nomenclature)

inside my c-mode-common-hook, personally.
-- 
Benjamin Rutt

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Java mixed case deletion
  2004-10-26 19:23 ` Benjamin Rutt
@ 2004-10-26 19:52   ` Mahesh Padmanabhan
  2004-10-26 22:41   ` Kevin Rodgers
  1 sibling, 0 replies; 4+ messages in thread
From: Mahesh Padmanabhan @ 2004-10-26 19:52 UTC (permalink / raw)


Benjamin Rutt wrote:
> Mahesh Padmanabhan <mahesh@privacy.net> writes:
> 
> 
>>The functions c-forward-into-nomenclature and
>>c-backward-into-nomenclature take care of negotiating mixed case words
>>but i could not find anything that allows me to delete while keeping
>>mixed case in mind.
>>
>>For example - if there is a word like this: SomeClass then a backward
>>delete word deletes the whole word. What I want is to delete just
>>Class in SomeClass.
> 
> 
> (defun my-c-kill-forward-into-nomenclature (&optional arg)
>   "Kill forward to the end of a nomenclature section or word.  With
> arg, do it arg times."
>   (interactive "p")
>   (save-excursion
>     (set-mark (point))
>     (c-forward-into-nomenclature arg)
>     (kill-region (mark) (point))))
> 
> (defun my-c-kill-backward-into-nomenclature (&optional arg)
>   "Kill backward to the beginning of a nomenclature section or word.
> th arg, do it arg times."
>   (interactive "p")
>   (save-excursion
>     (set-mark (point))
>     (c-backward-into-nomenclature arg)
>     (kill-region (mark) (point))))
> 
> Add those to your keys of choice in the hook and you're all set.  I
> use 
> 
>   (local-set-key [(control backspace)] 'my-c-kill-backward-into-nomenclature)
>   (local-set-key [(meta d)] 'my-c-kill-forward-into-nomenclature)
> 
> inside my c-mode-common-hook, personally.

Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Java mixed case deletion
  2004-10-26 19:23 ` Benjamin Rutt
  2004-10-26 19:52   ` Mahesh Padmanabhan
@ 2004-10-26 22:41   ` Kevin Rodgers
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2004-10-26 22:41 UTC (permalink / raw)


Benjamin Rutt wrote:
 > (defun my-c-kill-forward-into-nomenclature (&optional arg)
 >   "Kill forward to the end of a nomenclature section or word.  With
 > arg, do it arg times."
 >   (interactive "p")
 >   (save-excursion
 >     (set-mark (point))
 >     (c-forward-into-nomenclature arg)
 >     (kill-region (mark) (point))))
 >
 > (defun my-c-kill-backward-into-nomenclature (&optional arg)
 >   "Kill backward to the beginning of a nomenclature section or word.
 > th arg, do it arg times."
 >   (interactive "p")
 >   (save-excursion
 >     (set-mark (point))
 >     (c-backward-into-nomenclature arg)
 >     (kill-region (mark) (point))))

I think you can avoid the (save-excursion (set-mark ...) ...) construction:

(defun my-c-kill-forward-into-nomenclature (&optional n)
   "Kill forward to the end of a nomenclature section or word.
With a prefix arg, kill N names."
   (interactive "p")
   (kill-region (point)
                (progn
                  (c-forward-into-nomenclature n)
                  (point))))

(defun my-c-kill-backward-into-nomenclature (&optional n)
   "Kill backward to the beginning of a nomenclature section or word.
With a prefix arg, kill N names."
   (interactive "p")
   (kill-region (point)
                (progn
                  (c-backward-into-nomenclature n)
                  (point))))

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-10-26 22:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-26 17:21 Java mixed case deletion Mahesh Padmanabhan
2004-10-26 19:23 ` Benjamin Rutt
2004-10-26 19:52   ` Mahesh Padmanabhan
2004-10-26 22:41   ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).