all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Arni Magnusson <arnima@hafro.is>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 2887@emacsbugs.donarmstrong.com
Subject: bug#2887: Suggestions for simple.el
Date: Sun, 19 Apr 2009 01:13:05 +0000 (GMT)	[thread overview]
Message-ID: <alpine.LFD.0.9999.0904182215020.16457@localhost.localdomain> (raw)
In-Reply-To: <jwvprf9kf0y.fsf-monnier+emacsbugreports@gnu.org>

>> `backward-delete-word'
>> `delete-word'
>
> I would only consider some general "kill-next-kill" feature which would 
> allow to turn any killing command into a deleting one (e.g. a 
> kill-next-kill command which would cause the subsequent commands's 
> effect on the kill-ring to be cancelled).

This would mean two keystrokes to delete a word, right? First 
`kill-next-kill' and then `kill-word'. It's an idea, but I still believe 
that many users would appreciate binding single keystrokes to the 
functions I suggested. They would most likely bind them to C-backspace and 
C-delete.



>> `pos-at-beginning-of-line'
>> `pos-at-end-of-line'
>
> The reimplementation doesn't change anything: its performance will still 
> suck on large files.  It's just fundamentally an operation that is slow 
> and that we should generally avoid, so I don't want to add yet more ways 
> (additionally to goto-line) to do that.

I don't understand, I think these functions are blazing fast. In practice, 
I would probably not use Emacs to perform 100,000 iterations on a 200 MB 
file - but that's why I'm surprised to see that it takes less than a 
second:

   100000 M-x benchmark (pos-at-end-of-line 10)  ; 0.421s

I'm using a small arg of 10, because that's the case where you predicted 
that `line-end-position' would be much faster.

   100000 M-x benchmark (line-end-position 10)  ; 0.220s

This is necessarily faster, since `pos-at-end-of-line' calls 
`line-end-position', but the (save-excursion (goto-char (point-min)) 
overhead is not as great as one might expect.

With few iterations and large arg, the speed is also comparable:

   10 M-x benchmark (pos-at-end-of-line 100000)  ; 0.156s
   10 M-x benchmark (line-end-position 100000)   ; 0.156s

Most things become more sluggish with a 200 MB file. Overall, I think 
these functions make it considerably easier to read and write functions 
that operate on buffer text - with minimal performance cost. In practice, 
I use it without iteration, and with a 1 MB source code file it doesn't 
register in a benchmark (0.000000s).

I hesitate to introduce another function to the discussion, but here's an 
example where I use `pos-at-beginning-of-line' and `pos-at-end-of-line'. 
Since you're the maintainer of newcomment.el, it might pique your 
interest:

(defun comment-line-or-region ()
   "Comment line or region."
   (interactive)
   (require 'newcomment)
   (if (and mark-active transient-mark-mode)
       (comment-region
        (pos-at-beginning-of-line (line-number-at-pos (region-beginning)))
        (pos-at-end-of-line (line-number-at-pos (region-end))))
     (comment-region (line-beginning-position)(line-end-position))))

Same idea as `kill-line-or-region'. Without the `pos-at-beginning-of-line' 
and `pos-at-end-of-line',

       (comment-region
        (region-beginning)
        (region-end))

it would misbehave when the region consists of a partially selected first 
and/or last line. Someone like you might be able to improve this function, 
but it's served me well and has no discernible speed lag.



>> `delete-all-blank-lines'
>
> Can someone figure out a way to tweak flush-lines such that it can be 
> used for that purpose without having to jump through as many hooks? 
> Maybe we can just say that if you call flush-lines with an empty 
> argument (which currently would flush *all* lines) it will flush all 
> empty lines.

This is definitely an idea, making better use of the default value of the 
regexp. But do you really mean flush all empty lines, or just the empty 
lines below the point? The idea behind `delete-all-blank-lines' is to 
really delete all empty lines, without moving the point, in one keystroke. 
I could probably edit `flush-lines' to do exactly that, although it 
operates only on text after the point for non-default regexps.



Phew, it looks like the rest of our discussion threads have closed 
successfully, meaning that we have fully understood each others' ideas, 
and the decisions will depend on your good judgement and the Emacs elders.


Cheers,

Arni






  reply	other threads:[~2009-04-19  1:13 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-04 13:32 bug#2887: Suggestions for simple.el Arni Magnusson
2009-04-04 14:21 ` Stefan Monnier
2009-04-04 23:35   ` Arni Magnusson
2009-04-05  3:27     ` Stefan Monnier
2009-04-05 14:26       ` Leo
2009-04-05 20:17       ` Arni Magnusson
2009-04-05 21:59         ` Lennart Borgman
2009-04-06  2:14         ` Stefan Monnier
2009-04-06  3:02           ` Drew Adams
2009-04-07  2:46           ` Arni Magnusson
2009-04-07 14:02             ` Stefan Monnier
2009-04-07 16:09               ` Drew Adams
2009-04-07 17:18                 ` Stefan Monnier
2009-04-07 17:18                 ` Stefan Monnier
2009-04-07 17:22                 ` Chong Yidong
2009-04-07 17:26                   ` Drew Adams
2009-04-07 17:26                   ` Drew Adams
2009-04-07 21:43                   ` Stefan Monnier
2009-04-07 17:22                 ` Chong Yidong
2009-04-07 16:09               ` Drew Adams
2009-04-18  0:08               ` Arni Magnusson
2009-04-18 19:32                 ` Stefan Monnier
2009-04-19  1:13                   ` Arni Magnusson [this message]
2009-04-19  1:40                     ` Arni Magnusson
2009-04-19  3:14                     ` Stefan Monnier
2009-04-19 13:41                       ` Arni Magnusson
2020-09-19 21:50 ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.0.9999.0904182215020.16457@localhost.localdomain \
    --to=arnima@hafro.is \
    --cc=2887@emacsbugs.donarmstrong.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.