* count regexp hits @ 2018-01-04 4:12 Emanuel Berg 2018-01-04 5:02 ` Drew Adams [not found] ` <mailman.6799.1515042142.27995.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-04 4:12 UTC (permalink / raw) To: help-gnu-emacs Just wrote this [1] - is this somewhere already or is it so simple so you are expected to do it yourself? If so - well, don't count on it. I actually know many people incapable of writing any of this! (defun count-regexp-hits (regexp) (interactive "sregexp: ") (let ((hits 0)) (save-excursion (while (re-search-forward regexp (point-max) t) (cl-incf hits) )) (message "%d" hits) )) Example usage - eval me: %% how many books? (count-regexp-hits "@book") @book{fiberglass-boat-repair-manual, author = {Allan Vaitses}, ISBN = {0-07-156914-6}, publisher = {International Marine}, title = {The Fiberglass Boat Repair Manual}, year = 1988 } @book{savage-sword-of-conan-22, author = {Roy Thomas}, ISBN = 1616558717, publisher = {Dark Horse}, title = {Savage Sword of Conan 22}, year = 2016 } [1] http://user.it.uu.se/~embe8573/emacs-init/count.el -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* RE: count regexp hits 2018-01-04 4:12 count regexp hits Emanuel Berg @ 2018-01-04 5:02 ` Drew Adams [not found] ` <mailman.6799.1515042142.27995.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 41+ messages in thread From: Drew Adams @ 2018-01-04 5:02 UTC (permalink / raw) To: Emanuel Berg, help-gnu-emacs > Just wrote this [1] - is this somewhere already > or is it so simple so you are expected to do it > yourself? If so - well, don't count on it. > I actually know many people incapable of > writing any of this! > > (defun count-regexp-hits (regexp) > (interactive "sregexp: ") > (let ((hits 0)) > (save-excursion > (while (re-search-forward regexp (point-max) t) > (cl-incf hits) )) > (message "%d" hits) )) `C-h f count-matches': count-matches is an alias for `how-many' in `replace.el'. (count-matches REGEXP &optional RSTART REND INTERACTIVE) Print and return number of matches for REGEXP following point. When called from Lisp and INTERACTIVE is omitted or nil, just return the number, do not print it; if INTERACTIVE is t, the function behaves in all respects as if it had been called interactively. If REGEXP contains upper case characters (excluding those preceded by `\') and `search-upper-case' is non-nil, the matching is case-sensitive. Second and third arg RSTART and REND specify the region to operate on. Interactively, in Transient Mark mode when the mark is active, operate on the contents of the region. Otherwise, operate from point to the end of (the accessible portion of) the buffer. This function starts looking for the next match from the end of the previous match. Hence, it ignores matches that overlap a previously found match. ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.6799.1515042142.27995.help-gnu-emacs@gnu.org>]
* Re: count regexp hits [not found] ` <mailman.6799.1515042142.27995.help-gnu-emacs@gnu.org> @ 2018-01-04 18:47 ` Emanuel Berg 2018-01-04 21:32 ` DWIM region (was: Re: count regexp hits) Emanuel Berg 0 siblings, 1 reply; 41+ messages in thread From: Emanuel Berg @ 2018-01-04 18:47 UTC (permalink / raw) To: help-gnu-emacs Re: count regexp hits Drew Adams wrote: > `C-h f count-matches': > > count-matches is an alias for `how-many' in > `replace.el'. OK, thanks. (defun count-regexp-hits (regexp) (interactive "sregexp: ") (let*((region (if mark-active `(,(region-beginning) ,(region-end)) `(,(point-min) ,(point-max)) )) (start (car region)) (end (cadr region)) ) (count-matches regexp start end t) )) > (count-matches REGEXP &optional RSTART REND > INTERACTIVE) > > Print and return number of matches for REGEXP > following point. When called from Lisp and > INTERACTIVE Here the docstring mentions the arguments out of order but I suppose that truly is "bike-shedding" even tho I don't like that expression since everyone knows that bikes in light, bright colors (e.g., orange, cyan, and ocean blue) are faster than bikes with trunky, black and brown frames... -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* DWIM region (was: Re: count regexp hits) 2018-01-04 18:47 ` Emanuel Berg @ 2018-01-04 21:32 ` Emanuel Berg 2018-01-04 22:18 ` DWIM region Stefan Monnier ` (5 more replies) 0 siblings, 6 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-04 21:32 UTC (permalink / raw) To: help-gnu-emacs BTW this method on acting on the region (if any) I have found very useful and it has recurred many times in my code: (defun count-regexp-hits (regexp) (interactive "sregexp: ") (let*((region (if mark-active `(,(region-beginning) ,(region-end)) `(,(point-min) ,(point-max)) )) (start (car region)) (end (cadr region)) ) (count-matches regexp start end t) )) Is it the canonical way of doing it as well? -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-04 21:32 ` DWIM region (was: Re: count regexp hits) Emanuel Berg @ 2018-01-04 22:18 ` Stefan Monnier 2018-01-05 23:18 ` Philipp Stephani 2018-01-04 22:48 ` DWIM region (was: Re: count regexp hits) Kaushal Modi ` (4 subsequent siblings) 5 siblings, 1 reply; 41+ messages in thread From: Stefan Monnier @ 2018-01-04 22:18 UTC (permalink / raw) To: help-gnu-emacs > (defun count-regexp-hits (regexp) > (interactive "sregexp: ") > (let*((region (if mark-active > `(,(region-beginning) ,(region-end)) > `(,(point-min) ,(point-max)) )) 2 "errors": - you should check `use-region-p` instead of `mark-active`. - `region` should be an argument, so the use-region-p check is performed in the interactive spec rather than in the body of the function: (defun count-regexp-hits (regexp start end) (interactive ;; The "s" thingy from `interactive` corresponds to `read-string` ;; but we might as well use `read-regexp` here since we can. (let ((re (read-regexp "regexp: "))) (if (use-region-p) (list re (region-beginning) (region-end)) (list re (point-min) (point-max))))) (count-matches regexp start end t)) -- Stefan ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-04 22:18 ` DWIM region Stefan Monnier @ 2018-01-05 23:18 ` Philipp Stephani 0 siblings, 0 replies; 41+ messages in thread From: Philipp Stephani @ 2018-01-05 23:18 UTC (permalink / raw) To: Stefan Monnier; +Cc: help-gnu-emacs Stefan Monnier <monnier@iro.umontreal.ca> schrieb am Do., 4. Jan. 2018 um 23:19 Uhr: > > (defun count-regexp-hits (regexp) > > (interactive "sregexp: ") > > (let*((region (if mark-active > > `(,(region-beginning) ,(region-end)) > > `(,(point-min) ,(point-max)) )) > > 2 "errors": > - you should check `use-region-p` instead of `mark-active`. > - `region` should be an argument, so the use-region-p check is performed > in the interactive spec rather than in the body of the function: > > (defun count-regexp-hits (regexp start end) > (interactive > ;; The "s" thingy from `interactive` corresponds to `read-string` > ;; but we might as well use `read-regexp` here since we can. > (let ((re (read-regexp "regexp: "))) > (if (use-region-p) > (list re (region-beginning) (region-end)) > (list re (point-min) (point-max))))) > (count-matches regexp start end t)) > Since this pattern seems to be very common, would it make sense to add an interactive specifier 'R' that behaves like 'r' if `use-region-p` returns true and otherwise adds `nil, nil`? ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region (was: Re: count regexp hits) 2018-01-04 21:32 ` DWIM region (was: Re: count regexp hits) Emanuel Berg 2018-01-04 22:18 ` DWIM region Stefan Monnier @ 2018-01-04 22:48 ` Kaushal Modi [not found] ` <mailman.6836.1515106138.27995.help-gnu-emacs@gnu.org> ` (3 subsequent siblings) 5 siblings, 0 replies; 41+ messages in thread From: Kaushal Modi @ 2018-01-04 22:48 UTC (permalink / raw) To: Emanuel Berg; +Cc: help-gnu-emacs On Thu, Jan 4, 2018 at 4:35 PM Emanuel Berg <moasen@zoho.com> wrote: > BTW this method on acting on the region (if > any) I have found very useful and it has > recurred many times in my code: > > Is it the canonical way of doing it as well? > I don't think there's a canonical way.. here's how I dealt with the same problem: ;;; Operate on Region or Whole Buffer (defvar modi/region-or-whole-fns '(indent-region eval-region) "List of functions to act on the whole buffer if no region is selected.") (defun modi/advice-region-or-whole (orig-fun &rest args) "Advice function that applies ORIG-FUN to the whole buffer if no region is selected. http://thread.gmane.org/gmane.emacs.help/109025/focus=109102 " ;; Required to override the "r" argument of `interactive' in functions like ;; `indent-region' so that they can be called without an active region. (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (point-min) (point-max)))) (prog1 ; Return value of the advising fn needs to be the same as ORIG-FUN (apply orig-fun args) (when (and (called-interactively-p 'interactive) (not (use-region-p))) (message "Executed %s on the whole buffer." (propertize (symbol-name this-command) 'face 'font-lock-function-name-face))))) (dolist (fn modi/region-or-whole-fns) (advice-add fn :around #'modi/advice-region-or-whole)) Now with that setup, I simply need to add functions, where I want the same whole buffer or region behavior, to the modi/region-or-whole-fns variable. Ref: https://github.com/kaushalmodi/.emacs.d/blob/c7e3d5bae08105a7a1853566b44ea65c73c80e69/setup-files/setup-editing.el#L1001-L1028 -- Kaushal Modi ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.6836.1515106138.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region (was: Re: count regexp hits) [not found] ` <mailman.6836.1515106138.27995.help-gnu-emacs@gnu.org> @ 2018-01-04 23:03 ` Emanuel Berg 2018-01-04 23:14 ` Kaushal Modi ` (2 more replies) 0 siblings, 3 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-04 23:03 UTC (permalink / raw) To: help-gnu-emacs Kaushal Modi wrote: > (defun modi/advice-region-or-whole (orig-fun > &rest args) "Advice function that applies Sweet heaven! Advices make you crazy sooner rather than later... And especially for this simple task I dare not imagine how the rest of your system ever sticks together. But TEHO, of course... -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region (was: Re: count regexp hits) 2018-01-04 23:03 ` Emanuel Berg @ 2018-01-04 23:14 ` Kaushal Modi [not found] ` <mailman.6837.1515107666.27995.help-gnu-emacs@gnu.org> 2018-01-08 16:09 ` advice vs hooks in org (was DWIM region) Rusi 2 siblings, 0 replies; 41+ messages in thread From: Kaushal Modi @ 2018-01-04 23:14 UTC (permalink / raw) To: Emanuel Berg; +Cc: help-gnu-emacs On Thu, Jan 4, 2018 at 6:05 PM Emanuel Berg <moasen@zoho.com> wrote: > Sweet heaven! Advices make you crazy sooner > rather than later... And especially for this > simple task I dare not imagine how the rest of > your system ever sticks together. But TEHO, of > course... > Advices are especially useful for DRY use cases like this one. I prefer setting a solution just once and reuse it rather than rewriting whole functions. Many years ago, I too was scared of advices, but not any more once I started understanding them.. but as you said, TEHO.. I was just trying to help. -- Kaushal Modi ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.6837.1515107666.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region (was: Re: count regexp hits) [not found] ` <mailman.6837.1515107666.27995.help-gnu-emacs@gnu.org> @ 2018-01-05 2:10 ` Emanuel Berg 0 siblings, 0 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-05 2:10 UTC (permalink / raw) To: help-gnu-emacs Kaushal Modi wrote: > Many years ago, I too was scared of advices, > but not any more once I started understanding > them.. "What you once feared, now makes you free" (Scooter, "Stuck on Replay" 2010) That said, the mere thought of having tons of functions, all stacked together and intermingled in different ways, makes the blood retract from my feet and hands to protect the central parts... Scales of Set! I remember the "actions", "events", and "triggers" of certain unmentionable programming languages and IDEs. This always made for a total mess, instantly! It was like the very opposite of MVC built into the architecture and style of work, as a virtue! Having often ridiculed the "side-effect free" neurosis of Haskell people when it comes to functions I prefer them the predictable black box of school-boy calculus... -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* advice vs hooks in org (was DWIM region) 2018-01-04 23:03 ` Emanuel Berg 2018-01-04 23:14 ` Kaushal Modi [not found] ` <mailman.6837.1515107666.27995.help-gnu-emacs@gnu.org> @ 2018-01-08 16:09 ` Rusi 2 siblings, 0 replies; 41+ messages in thread From: Rusi @ 2018-01-08 16:09 UTC (permalink / raw) To: help-gnu-emacs On Friday, January 5, 2018 at 4:33:59 AM UTC+5:30, Emanuel Berg wrote: > Kaushal Modi wrote: > > > (defun modi/advice-region-or-whole (orig-fun > > &rest args) "Advice function that applies > > Sweet heaven! Advices make you crazy sooner > rather than later... And especially for this > simple task I dare not imagine how the rest of > your system ever sticks together. But TEHO, of > course... This reminds me… I find that org-protocol uses advice on server-visit-files to work Would it not have been possible to do it cleaner using the various server-hooks? [Ive spent the last several days trying to get it to work. Its particularly rough going since have to debug across firefox and emacs ] ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.6835.1515104325.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region [not found] ` <mailman.6835.1515104325.27995.help-gnu-emacs@gnu.org> @ 2018-01-04 23:09 ` Emanuel Berg 2018-01-04 23:14 ` Stefan Monnier [not found] ` <mailman.6838.1515107716.27995.help-gnu-emacs@gnu.org> 2018-01-04 23:20 ` Emanuel Berg 1 sibling, 2 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-04 23:09 UTC (permalink / raw) To: help-gnu-emacs Stefan Monnier wrote: > 2 "errors": - you should check `use-region-p` > instead of `mark-active`. - `region` should > be an argument, so the use-region-p check is > performed in the interactive spec rather than > in the body of the function: The byte compiler should warn about `mark-active' if you aren't allowed to use that ever - perhaps difficult to implement if indeed OK in other circumstances...? The rest I agree is better, thank you! Oh, no! Now I "have to" change tons of defuns that does this :) -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-04 23:09 ` DWIM region Emanuel Berg @ 2018-01-04 23:14 ` Stefan Monnier [not found] ` <mailman.6838.1515107716.27995.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 41+ messages in thread From: Stefan Monnier @ 2018-01-04 23:14 UTC (permalink / raw) To: help-gnu-emacs > The byte compiler should warn about > `mark-active' if you aren't allowed to use that > ever - perhaps difficult to implement if indeed > OK in other circumstances...? `mark-active` is a normal variable and you're perfectly allowed to use it (and modify it if you want). But in order to decide whether to use the region or not, `use-region-p` is the canonical way to test it (and it uses `mark-active` internally). It'd be very difficult for the byte-compiler to distinguish those uses of `mark-active` which would be better replaced by `use-region-p`. Stefan ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.6838.1515107716.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region [not found] ` <mailman.6838.1515107716.27995.help-gnu-emacs@gnu.org> @ 2018-01-04 23:36 ` Emanuel Berg 2018-01-05 0:19 ` Emanuel Berg 2018-01-05 20:45 ` Emanuel Berg 1 sibling, 1 reply; 41+ messages in thread From: Emanuel Berg @ 2018-01-04 23:36 UTC (permalink / raw) To: help-gnu-emacs Stefan Monnier wrote: > `mark-active` is a normal variable and you're > perfectly allowed to use it (and modify it if > you want). But in order to decide whether to > use the region or not, `use-region-p` is the > canonical way to test it (and it uses > `mark-active` internally). > > It'd be very difficult for the byte-compiler > to distinguish those uses of `mark-active` > which would be better replaced by > `use-region-p`. OK! But ironically, the new and improved function fails on the intitial use case - which did work when the region check was scornfully "performed ... in the body of the function" %% how many books? (count-regexp-hits "@book") @book{fiberglass-boat-repair-manual, author = {Allan Vaitses}, ISBN = {0-07-156914-6}, publisher = {International Marine}, title = {The Fiberglass Boat Repair Manual}, year = 1988 } @book{savage-sword-of-conan-22, author = {Roy Thomas}, ISBN = 1616558717, publisher = {Dark Horse}, title = {Savage Sword of Conan 22}, year = 2016 } -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-04 23:36 ` Emanuel Berg @ 2018-01-05 0:19 ` Emanuel Berg 0 siblings, 0 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-05 0:19 UTC (permalink / raw) To: help-gnu-emacs YT wrote: > But ironically, the new and improved function > fails on the intitial use case - which did work > when the region check was scornfully "performed > ... in the body of the function" > > %% how many books? (count-regexp-hits "@book") > > @book{fiberglass-boat-repair-manual, author = > {Allan Vaitses}, ISBN = {0-07-156914-6}, > publisher = {International Marine}, title = > {The Fiberglass Boat Repair Manual}, year = > 1988 } > > @book{savage-sword-of-conan-22, author = {Roy > Thomas}, ISBN = 1616558717, publisher = {Dark > Horse}, title = {Savage Sword of Conan 22}, > year = 2016 } It doesn't matter because it is almost impossible to do anything with it that way anyway. The only example I have came up with thus far is actually my original test which concluded it didn't work :) I guess one should consider the region an interactive feature? -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region [not found] ` <mailman.6838.1515107716.27995.help-gnu-emacs@gnu.org> 2018-01-04 23:36 ` Emanuel Berg @ 2018-01-05 20:45 ` Emanuel Berg 2018-01-05 22:31 ` Stefan Monnier [not found] ` <mailman.6892.1515191546.27995.help-gnu-emacs@gnu.org> 1 sibling, 2 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-05 20:45 UTC (permalink / raw) To: help-gnu-emacs I had 14 occurences of `mark-active' which I changed to `use-region-p' - save for one, which related to mark itself, not a prior test for region use. Perhaps a good rule of thumb? As for moving all the "in-body" tests into the `interactive' form - this will just brake the code and take several days to fix. Is it really that big an error? Anyway I'll leave them and instead do it the right way in the future, if God willing I haven't written my last Elisp :) -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-05 20:45 ` Emanuel Berg @ 2018-01-05 22:31 ` Stefan Monnier [not found] ` <mailman.6892.1515191546.27995.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 41+ messages in thread From: Stefan Monnier @ 2018-01-05 22:31 UTC (permalink / raw) To: help-gnu-emacs > 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! Stefan ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.6892.1515191546.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region [not found] ` <mailman.6892.1515191546.27995.help-gnu-emacs@gnu.org> @ 2018-01-06 2:20 ` Emanuel Berg 2018-01-06 15:53 ` Stefan Monnier [not found] ` <mailman.6929.1515254243.27995.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-06 2:20 UTC (permalink / raw) To: help-gnu-emacs 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 () (interactive) (let ((chars (if (use-region-p) (length (buffer-substring-no-properties (region-beginning) (region-end))) (buffer-size)) )) (message "%d" chars) )) (defun count-chars-karma (&optional start end) (interactive (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 http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-06 2:20 ` Emanuel Berg @ 2018-01-06 15:53 ` Stefan Monnier [not found] ` <mailman.6929.1515254243.27995.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 41+ messages in thread From: Stefan Monnier @ 2018-01-06 15:53 UTC (permalink / raw) To: help-gnu-emacs > (defun count-chars-karma (&optional start end) > (interactive > (if (use-region-p) > (list (region-beginning) (region-end)) > (list (point-min) (point-max)) )) > (let ((chars (length (buffer-substring-no-properties start end)))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (- end start) -- Stefan ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.6929.1515254243.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region [not found] ` <mailman.6929.1515254243.27995.help-gnu-emacs@gnu.org> @ 2018-01-06 18:52 ` Emanuel Berg 2018-01-06 20:29 ` Emanuel Berg 2018-01-06 22:14 ` Emanuel Berg 2 siblings, 0 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-06 18:52 UTC (permalink / raw) To: help-gnu-emacs Stefan Monnier wrote: >> (defun count-chars-karma (&optional start end) >> (interactive >> (if (use-region-p) >> (list (region-beginning) (region-end)) >> (list (point-min) (point-max)) )) >> (let ((chars (length (buffer-substring-no-properties start end)))) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > (- end start) OK, you dodged the bullet this time... -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region [not found] ` <mailman.6929.1515254243.27995.help-gnu-emacs@gnu.org> 2018-01-06 18:52 ` Emanuel Berg @ 2018-01-06 20:29 ` Emanuel Berg 2018-01-06 22:14 ` Emanuel Berg 2 siblings, 0 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-06 20:29 UTC (permalink / raw) To: help-gnu-emacs I'm starting to think this method in general has a positive impact not only on the hybrid interface but also on the function body... Here is another function, one I suspect is somewhere in vanilla Gnus as well, but what the heck. Anyway don't be confused by the word "mark" here where we previously have been talking about `mark' and regions - here, "mark" is in the `gnus-summary-mark-article' sense... BTW In Australian Survivor S4 there was an ex-elite soldier named Mark. He is also completely unrelated :) (defun gnus-summary-mark (char start stop) (interactive (let ((c (read-char "mark: "))) (if (use-region-p) (list c (region-beginning) (region-end)) (let*((strt (point)) (stp (1+ strt)) ) (list c strt stp) )))) (goto-char start) (beginning-of-line) (while (< (point) stop) (gnus-summary-mark-article (gnus-summary-article-number) char) (gnus-summary-find-next) )) -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region [not found] ` <mailman.6929.1515254243.27995.help-gnu-emacs@gnu.org> 2018-01-06 18:52 ` Emanuel Berg 2018-01-06 20:29 ` Emanuel Berg @ 2018-01-06 22:14 ` Emanuel Berg 2018-01-07 3:14 ` Emanuel Berg 2018-01-08 14:08 ` Stefan Monnier 2 siblings, 2 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-06 22:14 UTC (permalink / raw) To: help-gnu-emacs (defun w3m-bookmark-dwim (url &optional title) (interactive (if (use-region-p) (list w3m-current-url (buffer-substring (region-beginning) (region-end))) (let ((url-at-point (thing-at-point 'url))) (if url-at-point (list url-at-point) ; perhaps these two can... (let ((link-url (w3m-url-valid (w3m-anchor)))) ; be flipped! (if link-url (list link-url) ; (w3m-anchor-title) here DNC (list w3m-current-url w3m-current-title) )))))) (w3m-bookmark-add url title) ) -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-06 22:14 ` Emanuel Berg @ 2018-01-07 3:14 ` Emanuel Berg 2018-01-07 3:25 ` Emanuel Berg ` (2 more replies) 2018-01-08 14:08 ` Stefan Monnier 1 sibling, 3 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-07 3:14 UTC (permalink / raw) To: help-gnu-emacs 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 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-07 3:14 ` Emanuel Berg @ 2018-01-07 3:25 ` Emanuel Berg 2018-01-08 14:17 ` Stefan Monnier [not found] ` <mailman.7019.1515421057.27995.help-gnu-emacs@gnu.org> 2018-01-08 14:11 ` Stefan Monnier [not found] ` <mailman.7018.1515420745.27995.help-gnu-emacs@gnu.org> 2 siblings, 2 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-07 3:25 UTC (permalink / raw) To: help-gnu-emacs OK, I spoke to soon! There were *two* cases I didn't change. Here is the second one. The reason I didn't change this is the use of the prefix argument. If there is no interactive string, does that mean one has to check manually in the interactive form for a/the prefix argument? PS. Pretty cool code, ey? :) (defun fill-down (&optional justify) "Fill the current paragraph from the current line down.\n With mark active, act upon the region instead.\n With \\[universal-argument] before invocation, JUSTIFY fully. With \\[universal-argument] twice, remove full justification. (Or just fill it!) With \\[universal-argument] thrice, center." (interactive "P") (let*((area (if (use-region-p) (list (region-beginning) (region-end)) (list (line-beginning-position) (save-excursion (forward-paragraph) (point) )))) (start (car area)) (end (cadr area)) ) ;; C-u C-u -> unjustify (if (equal justify '(16)) (canonically-space-region start end) (fill-region start end ;; can't use cl-case here as compares with `elq' - bummer! (cond ((equal justify '(0)) nil) ; fill ((equal justify '(4)) 'full) ; C-u -> justify ((equal justify '(64)) 'center)) ; C-u C-u C-u -> center )))) -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-07 3:25 ` Emanuel Berg @ 2018-01-08 14:17 ` Stefan Monnier [not found] ` <mailman.7019.1515421057.27995.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 41+ messages in thread From: Stefan Monnier @ 2018-01-08 14:17 UTC (permalink / raw) To: help-gnu-emacs > If there is no interactive string, does that > mean one has to check manually in the > interactive form for a/the prefix argument? "P" just sends `current-prefix-arg` as argument. (defun fill-down (start end &optional justify) "Fill the current paragraph from the current line down.\n With mark active, act upon the region instead.\n With \\[universal-argument] before invocation, JUSTIFY fully. With \\[universal-argument] twice, remove full justification. (Or just fill it!) With \\[universal-argument] thrice, center." (interactive (if (use-region-p) (list (region-beginning) (region-end) current-prefix-arg) (list (line-beginning-position) (save-excursion (forward-paragraph) (point)) current-prefix-arg))) ;; C-u C-u -> unjustify (if (equal justify '(16)) (canonically-space-region start end) (fill-region start end (pcase justify ('(4) 'full) ; C-u -> justify ('(64)) 'center)))) ; C-u C-u C-u -> center -- Stefan ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.7019.1515421057.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region [not found] ` <mailman.7019.1515421057.27995.help-gnu-emacs@gnu.org> @ 2018-01-09 1:41 ` Emanuel Berg 2018-01-09 2:30 ` Stefan Monnier [not found] ` <mailman.7052.1515465048.27995.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-09 1:41 UTC (permalink / raw) To: help-gnu-emacs Stefan Monnier wrote: > "P" just sends `current-prefix-arg` > as argument. Right, easy. > (pcase justify > ('(4) 'full) ; C-u -> justify > ('(64)) 'center)))) ; C-u C-u C-u -> center `pcase' doesn't seem to do that? (pcase (car justify) (4 'full) ; C-u -> justify (64 'center) )))) ; C-u C-u C-u -> center ? -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-09 1:41 ` Emanuel Berg @ 2018-01-09 2:30 ` Stefan Monnier [not found] ` <mailman.7052.1515465048.27995.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 41+ messages in thread From: Stefan Monnier @ 2018-01-09 2:30 UTC (permalink / raw) To: help-gnu-emacs >> (pcase justify >> ('(4) 'full) ; C-u -> justify >> ('(64)) 'center)))) ; C-u C-u C-u -> center ^^ Sorry there was an spurious extra paren here. > `pcase' doesn't seem to do that? What makes you think so? It is not like CL's `case`. > (pcase (car justify) > (4 'full) ; C-u -> justify > (64 'center) )))) ; C-u C-u C-u -> center current-prefix-arg can also be a plain integer, so (car justify) can crash and burn. Stefan ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.7052.1515465048.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region [not found] ` <mailman.7052.1515465048.27995.help-gnu-emacs@gnu.org> @ 2018-01-09 4:11 ` Emanuel Berg 2018-01-09 13:40 ` Stefan Monnier 0 siblings, 1 reply; 41+ messages in thread From: Emanuel Berg @ 2018-01-09 4:11 UTC (permalink / raw) To: help-gnu-emacs Stefan Monnier wrote: >> `pcase' doesn't seem to do that? > > What makes you think so? It is not like CL's > `case`. Because I still don't get it to work! Actually it doesn't even eval (see below). For strings with the otherwise exact same syntax, as far as my programmer's eyes can see anyway, it does work. (setq dummy-list '(4)) (pcase dummy-list ('(4) 1) ('(16) 2) ) ; (error "Unknown upattern `(quote (4))'") in pcase--u1 (setq dummy-string "Shamen knocking on the door") (pcase dummy-string ("One two three four" 1) ("Shamen knocking on the door" 2) ) ; 2 > current-prefix-arg can also be a plain > integer, so (car justify) can crash and burn. (or (when (listp justify) (car justify)) justify) ? -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-09 4:11 ` Emanuel Berg @ 2018-01-09 13:40 ` Stefan Monnier 0 siblings, 0 replies; 41+ messages in thread From: Stefan Monnier @ 2018-01-09 13:40 UTC (permalink / raw) To: help-gnu-emacs > (setq dummy-list '(4)) > (pcase dummy-list > ('(4) 1) > ('(16) 2) ) ; (error "Unknown upattern `(quote (4))'") in pcase--u1 Ah, you're using an older Emacs than I thought. Try (pcase '(4) (`(4) 1) (`(16) 2) ) instead, Stefan ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-07 3:14 ` Emanuel Berg 2018-01-07 3:25 ` Emanuel Berg @ 2018-01-08 14:11 ` Stefan Monnier [not found] ` <mailman.7018.1515420745.27995.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 41+ messages in thread From: Stefan Monnier @ 2018-01-08 14:11 UTC (permalink / raw) To: help-gnu-emacs > 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? This is like a DWIMish function which does different things based on context, and indeed, in that case there's not much benefit to moving things into the interactive form. Stefan ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.7018.1515420745.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region [not found] ` <mailman.7018.1515420745.27995.help-gnu-emacs@gnu.org> @ 2018-01-08 20:26 ` Emanuel Berg 0 siblings, 0 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-08 20:26 UTC (permalink / raw) To: help-gnu-emacs Stefan Monnier wrote: > This is like a DWIMish function which does > different things based on context, and > indeed, in that case there's not much benefit > to moving things into the interactive form. You see? I was right all along! I'm moving everything back the way it was! Ha ha ha :D No, thanks for all your help :) -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-06 22:14 ` Emanuel Berg 2018-01-07 3:14 ` Emanuel Berg @ 2018-01-08 14:08 ` Stefan Monnier 1 sibling, 0 replies; 41+ messages in thread From: Stefan Monnier @ 2018-01-08 14:08 UTC (permalink / raw) To: help-gnu-emacs > (defun w3m-bookmark-dwim (url &optional title) > (interactive > (if (use-region-p) > (list w3m-current-url (buffer-substring (region-beginning) (region-end))) > (let ((url-at-point (thing-at-point 'url))) > (if url-at-point (list url-at-point) ; perhaps these two can... > (let ((link-url (w3m-url-valid (w3m-anchor)))) ; be flipped! > (if link-url (list link-url) ; (w3m-anchor-title) here DNC > (list w3m-current-url w3m-current-title) )))))) > (w3m-bookmark-add url title) ) You could get pretty much the same result by changing the `interactive` spec of w3m-bookmark-add. E.g. by changing w3m's source code, or with an advice, or with (put 'w3m-bookmark-add 'interactive-form `(funcall ',(lambda () (if (use-region-p) (list w3m-current-url (buffer-substring (region-beginning) (region-end))) (let ((url-at-point (thing-at-point 'url))) (if url-at-point (list url-at-point) ; perhaps these two can... (let ((link-url (w3m-url-valid (w3m-anchor)))) ; be flipped! (if link-url (list link-url) ; (w3m-anchor-title) here DNC (list w3m-current-url w3m-current-title) )))))))) -- Stefan ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region [not found] ` <mailman.6835.1515104325.27995.help-gnu-emacs@gnu.org> 2018-01-04 23:09 ` DWIM region Emanuel Berg @ 2018-01-04 23:20 ` Emanuel Berg 1 sibling, 0 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-04 23:20 UTC (permalink / raw) To: help-gnu-emacs Stefan Monnier wrote: > `region` should be an argument, so the > use-region-p check is performed in the > interactive spec rather than in the body of > the function So this is the magic behind `interactive'?! I always wondered about that! (defun interactive-ownz (echo-me) (interactive (list "You are lame")) (message echo-me) ) (interactive-ownz "Not so") -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region (was: Re: count regexp hits) 2018-01-04 21:32 ` DWIM region (was: Re: count regexp hits) Emanuel Berg ` (3 preceding siblings ...) [not found] ` <mailman.6835.1515104325.27995.help-gnu-emacs@gnu.org> @ 2018-01-07 5:32 ` Marcin Borkowski [not found] ` <mailman.6953.1515303153.27995.help-gnu-emacs@gnu.org> 5 siblings, 0 replies; 41+ messages in thread From: Marcin Borkowski @ 2018-01-07 5:32 UTC (permalink / raw) To: Emanuel Berg; +Cc: help-gnu-emacs On 2018-01-04, at 22:32, Emanuel Berg <moasen@zoho.com> wrote: > BTW this method on acting on the region (if > any) I have found very useful and it has > recurred many times in my code: > > (defun count-regexp-hits (regexp) > (interactive "sregexp: ") > (let*((region (if mark-active > `(,(region-beginning) ,(region-end)) > `(,(point-min) ,(point-max)) )) > (start (car region)) > (end (cadr region)) ) > (count-matches regexp start end t) )) > > Is it the canonical way of doing it as well? Why not use (use-region-p) instead of mark-active? Also, spacing is kind of strange. Hth, -- Marcin Borkowski ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.6953.1515303153.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region (was: Re: count regexp hits) [not found] ` <mailman.6953.1515303153.27995.help-gnu-emacs@gnu.org> @ 2018-01-07 6:45 ` Emanuel Berg 2018-01-07 7:21 ` Marcin Borkowski [not found] ` <mailman.6967.1515337253.27995.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-07 6:45 UTC (permalink / raw) To: help-gnu-emacs Marcin Borkowski wrote: > spacing is kind of strange. "spacing"? -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region (was: Re: count regexp hits) 2018-01-07 6:45 ` Emanuel Berg @ 2018-01-07 7:21 ` Marcin Borkowski [not found] ` <mailman.6967.1515337253.27995.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 41+ messages in thread From: Marcin Borkowski @ 2018-01-07 7:21 UTC (permalink / raw) To: Emanuel Berg; +Cc: help-gnu-emacs On 2018-01-07, at 07:45, Emanuel Berg <moasen@zoho.com> wrote: > Marcin Borkowski wrote: > >> spacing is kind of strange. > > "spacing"? (defun count-regexp-hits (regexp) (interactive "sregexp: ") (let*((region (if mark-active `(,(region-beginning) ,(region-end)) `(,(point-min) ,(point-max)) )) (start (car region)) (end (cadr region)) ) (count-matches regexp start end t) )) 1. Lack of space after `let*'. 2. Unnecessary space before `))` (twice). 3. Unnecessary double spaces in lines with `start' and `end' (I understand their purpose, but my OCD does not like them anyway). Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.6967.1515337253.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region (was: Re: count regexp hits) [not found] ` <mailman.6967.1515337253.27995.help-gnu-emacs@gnu.org> @ 2018-01-07 20:57 ` Emanuel Berg 2018-01-09 5:28 ` Marcin Borkowski [not found] ` <mailman.7055.1515475732.27995.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-07 20:57 UTC (permalink / raw) To: help-gnu-emacs Marcin Borkowski wrote: > 1. Lack of space after `let*'. This is so one can change `let' into `let*' and back without moving anything else. Personally, I wouldn't mind just one "let" which would be equal to `let*', as legend has it the supposed parallelism of `let' is an urban legend, however now when it is like it is it would be confusing (to other people) to always use `let*' when there is no reason to, even tho there is equally little/as much reason to use plain `let'... > 2. Unnecessary space before `))` (twice). This style I got from this book: @book{land-of-lisp, author = {Conrad Barski}, ISBN = 1593272812, publisher = {No Starch}, title = {Land of Lisp}, year = 2010 } It was one of the first books on Lisp that I read and I think the only one I completed. I've heard CL people don't like that style. But now that I say it I actually don't remember what dialect was used in the book. For sure it wasn't Elisp. > 3. Unnecessary double spaces in lines with > `start' and `end' (I understand their > purpose, but my OCD does not like them > anyway). That's known as indentation. If it looks strange to anyone, perhaps it is time to stop using Comic Sans MS as the default font...? -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region (was: Re: count regexp hits) 2018-01-07 20:57 ` Emanuel Berg @ 2018-01-09 5:28 ` Marcin Borkowski 2018-01-09 13:42 ` DWIM region Stefan Monnier [not found] ` <mailman.7069.1515505638.27995.help-gnu-emacs@gnu.org> [not found] ` <mailman.7055.1515475732.27995.help-gnu-emacs@gnu.org> 1 sibling, 2 replies; 41+ messages in thread From: Marcin Borkowski @ 2018-01-09 5:28 UTC (permalink / raw) To: Emanuel Berg; +Cc: help-gnu-emacs On 2018-01-07, at 21:57, Emanuel Berg <moasen@zoho.com> wrote: > Marcin Borkowski wrote: > >> 1. Lack of space after `let*'. > > This is so one can change `let' into `let*' and > back without moving anything else. > > Personally, I wouldn't mind just one "let" > which would be equal to `let*', as legend has > it the supposed parallelism of `let' is an > urban legend, however now when it is like it is > it would be confusing (to other people) to > always use `let*' when there is no reason to, > even tho there is equally little/as much reason > to use plain `let'... Well, for me, `let*' is an indication that `let' is not enough. But it's a minor point, agreed. I don't know about relative efficiency of both. >> 2. Unnecessary space before `))` (twice). > > This style I got from this book: > > @book{land-of-lisp, > author = {Conrad Barski}, > ISBN = 1593272812, > publisher = {No Starch}, > title = {Land of Lisp}, > year = 2010 > } > > It was one of the first books on Lisp that > I read and I think the only one I completed. > I've heard CL people don't like that style. > But now that I say it I actually don't remember > what dialect was used in the book. For sure it > wasn't Elisp. Well, that is really strange. Could you explain the reason for this space being there and not somewhere else? >> 3. Unnecessary double spaces in lines with >> `start' and `end' (I understand their >> purpose, but my OCD does not like them >> anyway). > > That's known as indentation. If it looks > strange to anyone, perhaps it is time to stop > using Comic Sans MS as the default font...? Well, it's not standard, I'd think. And for me, `indentation' is at the bol, this I'd call `alignment'. And again, I do understand the reason, I just don't like this style. It's not something I'm accustomed to. ,----[ Paul Halmos in "How to write mathematics" said ] | [W]henever the “reform” is introduced it is bound to cause distraction, | and therefore a waste of time, and the “saving” is not worth it. `---- Best, -- Marcin Borkowski ^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: DWIM region 2018-01-09 5:28 ` Marcin Borkowski @ 2018-01-09 13:42 ` Stefan Monnier [not found] ` <mailman.7069.1515505638.27995.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 41+ messages in thread From: Stefan Monnier @ 2018-01-09 13:42 UTC (permalink / raw) To: help-gnu-emacs > Well, that is really strange. Could you explain the reason for this > space being there and not somewhere else? It separates close parens whose matching opener is on the same line from those whose matching opener is one previous lines. Not sure why that would be important, tho. Stefan ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.7069.1515505638.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region [not found] ` <mailman.7069.1515505638.27995.help-gnu-emacs@gnu.org> @ 2018-01-10 3:31 ` Emanuel Berg 0 siblings, 0 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-10 3:31 UTC (permalink / raw) To: help-gnu-emacs Stefan Monnier wrote: > It separates close parens whose matching > opener is on the same line from those whose > matching opener is one previous lines. Yes, with the possible exception (I know a list that will get on your mind get on your mind get on your mind) > Not sure why that would be important, tho. Some say the Lisp or LISP acronym is for "Lots of Irritating Superfluous Parenthesis". Other say I'm in complete denial. But neither are true! Well, there can be a small repetition of parenthesis at the end of a long defun. This indentation/spacing style, while perhaps of an artificial nature, is one method as good as any of breaking them up into smaller units. Second, it is a way to keep alert. You know when they teach very young men (?) to march in the army? The first (left) step, everyone says "ONE", the second (right) step, everyone says "TWO", but the third (left) step, no one should say anything! and the fourth (right) step, everyone shouts "FOUR" to complete the sequence. A kid can understand this rule, intended as to not fall into a completely hypnotic trance (because that would be to pleasant for army life, and besides detrimental if the enemy attacks while the troops march by in a dreamy state without notice). However understanding is not the same as doing, and if there are a hundred guys marching (this is not the US or Israel, we almost don't have any female soldiers), if a hundred guys are doing it, and mental/physical fatigue sets in, there will always be one dude who alone shouts "THREE" in a loud and self-confident voice. And the sarge will get angrier and angrier shouting "THERE IS NO THREE!" back each time with a red face. You see? It's a very pleasant game. -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
[parent not found: <mailman.7055.1515475732.27995.help-gnu-emacs@gnu.org>]
* Re: DWIM region (was: Re: count regexp hits) [not found] ` <mailman.7055.1515475732.27995.help-gnu-emacs@gnu.org> @ 2018-01-09 6:20 ` Emanuel Berg 0 siblings, 0 replies; 41+ messages in thread From: Emanuel Berg @ 2018-01-09 6:20 UTC (permalink / raw) To: help-gnu-emacs Marcin Borkowski wrote: >>> 1. Lack of space after `let*'. This is so >>> one can change `let' into `let*' and back >>> without moving anything else. Personally, >>> I wouldn't mind just one "let" which would >>> be equal to `let*', as legend has it the >>> supposed parallelism of `let' is an urban >>> legend, however now when it is like it is >>> it would be confusing (to other people) to >>> always use `let*' when there is no reason >>> to, even tho there is equally little/as >>> much reason to use plain `let'... > > Well, for me, `let*' is an indication that > `let' is not enough. But it's a minor point, > agreed. I don't know about relative > efficiency of both. Yes, that is the indication we are used to see. So that is why it has to be used like that (it makes sense to use it like that) even tho technically it doesn't matter because there is no parallelism lost in `let' when using `let*'. So one could use `let*' all the time and not have to think about it and not have the bug/confusion when one changes something but forgets to change the asterisk. This is what I've heard; I haven't browsed the C source myself if anyone wants to look for the lost parallelism. But my bet it'll be even more difficult to find than the proverbial microchip in the supercomputer... > Well, that is really strange. Could you > explain the reason for this space being there > and not somewhere else? (yes (it is based) (on what happens on each line) ) > Well, it's not standard, I'd think. And for > me, `indentation' is at the bol, this I'd > call `alignment'. Alignment of code is a part of indentation. > And again, I do understand the reason, I just > don't like this style. It's not something I'm > accustomed to. The reason is to group items, for example artefacts, relics, treasures, wierd magical materia, and other things that are on the same level, together, to increase "seeing" and decrease "reading". PS. If anyone looking at the above example without understanding it might be you have a mail client/newsreader that messes that up. If so, this is your luckiest computer day of 2018 so far, as that should be *disabled* first thing and then never touched upon again, ever. -- underground experts united http://user.it.uu.se/~embe8573 ^ permalink raw reply [flat|nested] 41+ messages in thread
end of thread, other threads:[~2018-01-10 3:31 UTC | newest] Thread overview: 41+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-01-04 4:12 count regexp hits Emanuel Berg 2018-01-04 5:02 ` Drew Adams [not found] ` <mailman.6799.1515042142.27995.help-gnu-emacs@gnu.org> 2018-01-04 18:47 ` Emanuel Berg 2018-01-04 21:32 ` DWIM region (was: Re: count regexp hits) Emanuel Berg 2018-01-04 22:18 ` DWIM region Stefan Monnier 2018-01-05 23:18 ` Philipp Stephani 2018-01-04 22:48 ` DWIM region (was: Re: count regexp hits) Kaushal Modi [not found] ` <mailman.6836.1515106138.27995.help-gnu-emacs@gnu.org> 2018-01-04 23:03 ` Emanuel Berg 2018-01-04 23:14 ` Kaushal Modi [not found] ` <mailman.6837.1515107666.27995.help-gnu-emacs@gnu.org> 2018-01-05 2:10 ` Emanuel Berg 2018-01-08 16:09 ` advice vs hooks in org (was DWIM region) Rusi [not found] ` <mailman.6835.1515104325.27995.help-gnu-emacs@gnu.org> 2018-01-04 23:09 ` DWIM region Emanuel Berg 2018-01-04 23:14 ` Stefan Monnier [not found] ` <mailman.6838.1515107716.27995.help-gnu-emacs@gnu.org> 2018-01-04 23:36 ` Emanuel Berg 2018-01-05 0:19 ` Emanuel Berg 2018-01-05 20:45 ` Emanuel Berg 2018-01-05 22:31 ` Stefan Monnier [not found] ` <mailman.6892.1515191546.27995.help-gnu-emacs@gnu.org> 2018-01-06 2:20 ` Emanuel Berg 2018-01-06 15:53 ` Stefan Monnier [not found] ` <mailman.6929.1515254243.27995.help-gnu-emacs@gnu.org> 2018-01-06 18:52 ` Emanuel Berg 2018-01-06 20:29 ` Emanuel Berg 2018-01-06 22:14 ` Emanuel Berg 2018-01-07 3:14 ` Emanuel Berg 2018-01-07 3:25 ` Emanuel Berg 2018-01-08 14:17 ` Stefan Monnier [not found] ` <mailman.7019.1515421057.27995.help-gnu-emacs@gnu.org> 2018-01-09 1:41 ` Emanuel Berg 2018-01-09 2:30 ` Stefan Monnier [not found] ` <mailman.7052.1515465048.27995.help-gnu-emacs@gnu.org> 2018-01-09 4:11 ` Emanuel Berg 2018-01-09 13:40 ` Stefan Monnier 2018-01-08 14:11 ` Stefan Monnier [not found] ` <mailman.7018.1515420745.27995.help-gnu-emacs@gnu.org> 2018-01-08 20:26 ` Emanuel Berg 2018-01-08 14:08 ` Stefan Monnier 2018-01-04 23:20 ` Emanuel Berg 2018-01-07 5:32 ` DWIM region (was: Re: count regexp hits) Marcin Borkowski [not found] ` <mailman.6953.1515303153.27995.help-gnu-emacs@gnu.org> 2018-01-07 6:45 ` Emanuel Berg 2018-01-07 7:21 ` Marcin Borkowski [not found] ` <mailman.6967.1515337253.27995.help-gnu-emacs@gnu.org> 2018-01-07 20:57 ` Emanuel Berg 2018-01-09 5:28 ` Marcin Borkowski 2018-01-09 13:42 ` DWIM region Stefan Monnier [not found] ` <mailman.7069.1515505638.27995.help-gnu-emacs@gnu.org> 2018-01-10 3:31 ` Emanuel Berg [not found] ` <mailman.7055.1515475732.27995.help-gnu-emacs@gnu.org> 2018-01-09 6:20 ` DWIM region (was: Re: count regexp hits) Emanuel Berg
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).