Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: [emacs] automatically indent to comment-column

by LanX (Saint)
on May 12, 2010 at 10:23 UTC ( #839593=note: print w/replies, xml ) Need Help??


in reply to [emacs] automatically indent to comment-column

The following code will let "backspace" correct an unwanted jump to comment-column, deleting all previously inserted whitespaces.

example of phases before and after typing bla();#<backspace> (cursor position marked by «)

... bla();« bla(); # « bla();«

elisp:

(defun my-cperl-electric-backspace (arg) "(Wrapper for my electric commands) Remove inserted whitespaces or call `cperl-electric-backspace'" (interactive "p") (if (not (eq last-command 'my-indent-for-comment )) (cperl-electric-backspace arg) (setq p (point)) (skip-chars-backward "# \t") (delete-region (point) p) ) ) (add-hook 'cperl-mode-hook (lambda () (local-set-key (kbd "C-#") 'comment-dwim) (local-set-key (kbd "#") 'my-indent-for-comment) (local-set-key (kbd "DEL") 'my-cperl-electric-backspace) (set-variable 'cperl-comment-column 60 ) ))

Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://839593]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2023-12-23 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (56 votes). Check out past polls.

    Notices?