[Top][All Lists]

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

Re: DWIM region

From: Emanuel Berg
Subject: Re: DWIM region
Date: Sat, 06 Jan 2018 03:20:51 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Stefan Monnier wrote:

>> code and take several days to fix. Is it
>> really that big an error?
> Your karma will suffer if you don't fix
> them promptly!

Oh, no!

I'm actually very concerned about my karma...

OK, if I do it, perhaps there will be new
questions that will be interesting to discuss.

Here is one! As you see in the original
version, the methods of finding out differ!
In the second version, while the code looks
much better, this opportunity is lost...

(defun count-chars ()
  (let ((chars (if (use-region-p)
                   (length (buffer-substring-no-properties (region-beginning) 
                 (buffer-size)) ))
    (message "%d" chars) ))

(defun count-chars-karma (&optional start end)
   (if (use-region-p)
       (list (region-beginning) (region-end))
     (list (point-min) (point-max)) ))
  (let ((chars (length (buffer-substring-no-properties start end))))
    (message "%d" chars) ))

underground experts united

reply via email to

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