[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DWIM region
From: |
Emanuel Berg |
Subject: |
Re: DWIM region |
Date: |
Sun, 07 Jan 2018 04:14:53 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Now I have changed every single case save for
one! But most of the ones I changed I didn't
post here since it was trivial repetition of
the same procedure with expected results.
However this is the one I didn't change. As you
see, there are 4 different cases and only one -
the region case - does it with numbers.
So can that really be incorporated into the
interactive form in a neat way, or does one
have to live with - for the rest of one's life
- that the region check is actually done in the
function body which otherwise is
strongly disencouraged?
(defun is-code () (member major-mode '(
c++-mode
emacs-lisp-mode
sh-mode
Shell-script-mode
))) ; add more!
(defun is-message () (eq major-mode 'message-mode))
(defun spell (dict)
"Spell with DICT.
If there is a region, `ispell-region';
if in a code mode, `ispell-comments-and-strings';
if in `message-mode', `ispell-message';
otherwise, `ispell-buffer'."
(ispell-change-dictionary dict)
(save-excursion
(cond
((use-region-p) (ispell-region (region-beginning) (region-end)))
((is-message) (ispell-message))
((is-code) (ispell-comments-and-strings nil)) ; ONLY-CURRENT
(t (ispell-buffer)) )))
(defun spell-swedish ()
(interactive)
(spell swe-dict))
(defun spell-english ()
(interactive)
(spell eng-dict))
--
underground experts united
http://user.it.uu.se/~embe8573
- Re: DWIM region, (continued)
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/05
- Re: DWIM region, Stefan Monnier, 2018/01/05
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/05
- Re: DWIM region, Stefan Monnier, 2018/01/06
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/06
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/06
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/06
- Re: DWIM region,
Emanuel Berg <=
- Re: DWIM region, Emanuel Berg, 2018/01/06
- Re: DWIM region, Stefan Monnier, 2018/01/08
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/08
- Re: DWIM region, Stefan Monnier, 2018/01/08
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/08
- Re: DWIM region, Stefan Monnier, 2018/01/09
- Re: DWIM region, Stefan Monnier, 2018/01/08
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/08
- Re: DWIM region, Stefan Monnier, 2018/01/08
- Message not available
- Re: DWIM region, Emanuel Berg, 2018/01/04