unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Mac: Don't quit Emacs when window is closed
@ 2016-01-17 20:07 Luis Gerhorst
  2016-01-17 22:40 ` Marcin Borkowski
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Luis Gerhorst @ 2016-01-17 20:07 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,
I have the problem that I always quit Emacs by mistake when I am done with a task by clicking the button to close the Emacs window. I have a few ideas / questions:

- Wouldn't it be a good idea to make Emacs act like most Mac application and not quit the application when the window is closed? Is there some reason why this is not possible?
- How can I disable the button to close the window or make it call suspend-frame instead of save-buffers-kill-emacs?

Best wishes from Germany,
Luis Gerhorst




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Mac: Don't quit Emacs when window is closed
  2016-01-17 20:07 Mac: Don't quit Emacs when window is closed Luis Gerhorst
@ 2016-01-17 22:40 ` Marcin Borkowski
  2016-01-18  4:21   ` Random832
       [not found]   ` <mailman.2484.1453090928.843.help-gnu-emacs@gnu.org>
  2016-01-18  7:15 ` Mac: Don't quit Emacs when window is closed Nick Helm
  2016-01-18  9:11 ` tomas
  2 siblings, 2 replies; 15+ messages in thread
From: Marcin Borkowski @ 2016-01-17 22:40 UTC (permalink / raw)
  To: Luis Gerhorst; +Cc: help-gnu-emacs


On 2016-01-17, at 21:07, Luis Gerhorst <privat@luisgerhorst.de> wrote:

> Hi,
> I have the problem that I always quit Emacs by mistake when I am done with a task by clicking the button to close the Emacs window. I have a few ideas / questions:
>
> - Wouldn't it be a good idea to make Emacs act like most Mac application and not quit the application when the window is closed? Is there some reason why this is not possible?
> - How can I disable the button to close the window or make it call suspend-frame instead of save-buffers-kill-emacs?

Would this help a bit?

(setq confirm-kill-emacs #'yes-or-no-p)

> Best wishes from Germany,
> Luis Gerhorst

Hth,

-- 
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] 15+ messages in thread

* Re: Mac: Don't quit Emacs when window is closed
  2016-01-17 22:40 ` Marcin Borkowski
@ 2016-01-18  4:21   ` Random832
  2016-01-19 18:31     ` Luis Gerhorst
       [not found]   ` <mailman.2484.1453090928.843.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 15+ messages in thread
From: Random832 @ 2016-01-18  4:21 UTC (permalink / raw)
  To: help-gnu-emacs

Marcin Borkowski <mbork@mbork.pl> writes:
> Would this help a bit?
>
> (setq confirm-kill-emacs #'yes-or-no-p)

The wider issue is that people expect to be able to close all windows
and keep an app open (the menu remains open). This "kind of but not
really" works in Emacs server mode, and doesn't work at all [but at
least doesn't get in a weird half-state] with normal single-session GUI
usage.




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Mac: Don't quit Emacs when window is closed
  2016-01-17 20:07 Mac: Don't quit Emacs when window is closed Luis Gerhorst
  2016-01-17 22:40 ` Marcin Borkowski
@ 2016-01-18  7:15 ` Nick Helm
  2016-01-19 18:35   ` Luis Gerhorst
  2016-01-18  9:11 ` tomas
  2 siblings, 1 reply; 15+ messages in thread
From: Nick Helm @ 2016-01-18  7:15 UTC (permalink / raw)
  To: Luis Gerhorst; +Cc: help-gnu-emacs


> I have the problem that I always quit Emacs by mistake when I am done
> with a task by clicking the button to close the Emacs window. I have a
> few ideas / questions:
>
> - Wouldn't it be a good idea to make Emacs act like most Mac
> application and not quit the application when the window is closed? Is
> there some reason why this is not possible?
> - How can I disable the button to close the window or make it call
> suspend-frame instead of save-buffers-kill-emacs?

I wanted to do something similar on my mac-port emacs a while back and
added this to my init.el:

   (defun nick-mac-hide-last-frame (orig-fun &rest args)
      "Check if last visible frame is being closed and hide it instead."
      (if (and (featurep 'mac)
               (display-graphic-p nil)
               (= 1 (length (frame-list)))) (progn 
         (when (eq (frame-parameter (selected-frame) 'fullscreen) 'fullscreen)
            (set-frame-parameter (selected-frame) 'fullscreen nil) 
            (sit-for 1.2))
         (mac-do-applescript "tell application \"System Events\" \
            to tell process \"Emacs\" to set visible to false")
         (sit-for 1.5)
         (modify-frame-parameters (selected-frame) default-frame-alist)
         (delete-other-windows)
         (switch-to-buffer "*scratch*"))
        (apply orig-fun args)))

   (defun nick-handle-delete-frame (event)
      "Hide last visible frame when clicking frame close button."
      (interactive "e")
      (let ((frame (posn-window (event-start event))))
         (delete-frame frame t)))

   (defun nick-save-buffers-kill-terminal (&optional arg)
      "Hide last visible frame instead of closing Emacs."
      (interactive "P")
      (delete-frame (selected-frame) t))

   (advice-add 'delete-frame :around #'nick-mac-hide-last-frame)
   (advice-add 'handle-delete-frame :override #'nick-handle-delete-frame)
   (advice-add 'save-buffers-kill-terminal :override 
      #'nick-save-buffers-kill-terminal)

This uses applescript to hide the last frame instead of closing it. The
OS takes care of the unhiding when you click on the dock icon, relaunch
the app, double click a file, etc. Do Emacs > Quit Emacs or `kill-emacs'
to exit.

It doesn't leave the emacs menubar visible after a frame is closed, but
I've not found that to be a problem in practice. 

If you don't use the mac-port you can probably do the same thing by
dropping in ns-do-applescript, although I haven't tried it. 

Nick



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Mac: Don't quit Emacs when window is closed
  2016-01-17 20:07 Mac: Don't quit Emacs when window is closed Luis Gerhorst
  2016-01-17 22:40 ` Marcin Borkowski
  2016-01-18  7:15 ` Mac: Don't quit Emacs when window is closed Nick Helm
@ 2016-01-18  9:11 ` tomas
  2 siblings, 0 replies; 15+ messages in thread
From: tomas @ 2016-01-18  9:11 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Jan 17, 2016 at 09:07:46PM +0100, Luis Gerhorst wrote:
> Hi,
> I have the problem that I always quit Emacs by mistake when I am
> done with a task by clicking the button to close the Emacs window.
> I have a few ideas / questions:

Isn't that what emacsserver/emacsclient was born for?

Sorry I'm not very strong on Mac specifics.

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlacrFwACgkQBcgs9XrR2kZ3DwCdHzJO5KQHljkGxaCujuvtGAi4
/j0An00T/4cvQwGijJI+JsA9o9e8UZIv
=LruL
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Mac: Don't quit Emacs when window is closed
       [not found]   ` <mailman.2484.1453090928.843.help-gnu-emacs@gnu.org>
@ 2016-01-18 17:05     ` Barry Margolin
  2016-01-18 18:03       ` Philipp Stephani
  2016-01-21 17:36       ` repeating a search a certain number of times Timur Aydin
  0 siblings, 2 replies; 15+ messages in thread
From: Barry Margolin @ 2016-01-18 17:05 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.2484.1453090928.843.help-gnu-emacs@gnu.org>,
 Random832 <random832@fastmail.com> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
> > Would this help a bit?
> >
> > (setq confirm-kill-emacs #'yes-or-no-p)
> 
> The wider issue is that people expect to be able to close all windows
> and keep an app open (the menu remains open).

It's perfectly normal and expected for Mac applications, which is one of 
the reasons why the Mac menu bar is attached to the screen, not 
individual windows. Some single-window applications automatically quit 
when you close that window, but this would be unusual for multi-window 
applications.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Mac: Don't quit Emacs when window is closed
  2016-01-18 17:05     ` Barry Margolin
@ 2016-01-18 18:03       ` Philipp Stephani
  2016-01-21 17:36       ` repeating a search a certain number of times Timur Aydin
  1 sibling, 0 replies; 15+ messages in thread
From: Philipp Stephani @ 2016-01-18 18:03 UTC (permalink / raw)
  To: Barry Margolin, help-gnu-emacs

Barry Margolin <barmar@alum.mit.edu> schrieb am Mo., 18. Jan. 2016 um
18:10 Uhr:

> In article <mailman.2484.1453090928.843.help-gnu-emacs@gnu.org>,
>  Random832 <random832@fastmail.com> wrote:
>
> > Marcin Borkowski <mbork@mbork.pl> writes:
> > > Would this help a bit?
> > >
> > > (setq confirm-kill-emacs #'yes-or-no-p)
> >
> > The wider issue is that people expect to be able to close all windows
> > and keep an app open (the menu remains open).
>
> It's perfectly normal and expected for Mac applications, which is one of
> the reasons why the Mac menu bar is attached to the screen, not
> individual windows. Some single-window applications automatically quit
> when you close that window, but this would be unusual for multi-window
> applications.
>
>
Basically, Emacs should run the equivalent of (delete-frame nil :force)
when closing its window on OS X, not kill-emacs. When clicking the dock
icon without a frame present, a new one should be created with e.g.
make-frame.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Mac: Don't quit Emacs when window is closed
  2016-01-18  4:21   ` Random832
@ 2016-01-19 18:31     ` Luis Gerhorst
  0 siblings, 0 replies; 15+ messages in thread
From: Luis Gerhorst @ 2016-01-19 18:31 UTC (permalink / raw)
  To: Random832; +Cc: help-gnu-emacs

So it's not possible for Emacs to have no frames and still be running?

> On 18.01.2016, at 05:21, Random832 <random832@fastmail.com> wrote:
> 
> Marcin Borkowski <mbork@mbork.pl> writes:
>> Would this help a bit?
>> 
>> (setq confirm-kill-emacs #'yes-or-no-p)
> 
> The wider issue is that people expect to be able to close all windows
> and keep an app open (the menu remains open). This "kind of but not
> really" works in Emacs server mode, and doesn't work at all [but at
> least doesn't get in a weird half-state] with normal single-session GUI
> usage.
> 
> 




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Mac: Don't quit Emacs when window is closed
  2016-01-18  7:15 ` Mac: Don't quit Emacs when window is closed Nick Helm
@ 2016-01-19 18:35   ` Luis Gerhorst
  2016-01-19 21:46     ` Luis Gerhorst
  2016-01-19 22:04     ` Nick Helm
  0 siblings, 2 replies; 15+ messages in thread
From: Luis Gerhorst @ 2016-01-19 18:35 UTC (permalink / raw)
  To: Nick Helm; +Cc: help-gnu-emacs

Thanks! I tried it but it gives me some error in GNU Emacs. For the beginning I instead added this code wich make C-z no longer painful on OS X:

(when (eq system-type 'darwin)
  (global-set-key [remap suspend-frame] 'ns-do-hide-emacs))

Without it the Emacs window minimizes slowly into the dock on my iMac 27" Retina.

> On 18.01.2016, at 08:15, Nick Helm <nick@tenpoint.co.nz> wrote:
> 
> 
>> I have the problem that I always quit Emacs by mistake when I am done
>> with a task by clicking the button to close the Emacs window. I have a
>> few ideas / questions:
>> 
>> - Wouldn't it be a good idea to make Emacs act like most Mac
>> application and not quit the application when the window is closed? Is
>> there some reason why this is not possible?
>> - How can I disable the button to close the window or make it call
>> suspend-frame instead of save-buffers-kill-emacs?
> 
> I wanted to do something similar on my mac-port emacs a while back and
> added this to my init.el:
> 
>   (defun nick-mac-hide-last-frame (orig-fun &rest args)
>      "Check if last visible frame is being closed and hide it instead."
>      (if (and (featurep 'mac)
>               (display-graphic-p nil)
>               (= 1 (length (frame-list)))) (progn 
>         (when (eq (frame-parameter (selected-frame) 'fullscreen) 'fullscreen)
>            (set-frame-parameter (selected-frame) 'fullscreen nil) 
>            (sit-for 1.2))
>         (mac-do-applescript "tell application \"System Events\" \
>            to tell process \"Emacs\" to set visible to false")
>         (sit-for 1.5)
>         (modify-frame-parameters (selected-frame) default-frame-alist)
>         (delete-other-windows)
>         (switch-to-buffer "*scratch*"))
>        (apply orig-fun args)))
> 
>   (defun nick-handle-delete-frame (event)
>      "Hide last visible frame when clicking frame close button."
>      (interactive "e")
>      (let ((frame (posn-window (event-start event))))
>         (delete-frame frame t)))
> 
>   (defun nick-save-buffers-kill-terminal (&optional arg)
>      "Hide last visible frame instead of closing Emacs."
>      (interactive "P")
>      (delete-frame (selected-frame) t))
> 
>   (advice-add 'delete-frame :around #'nick-mac-hide-last-frame)
>   (advice-add 'handle-delete-frame :override #'nick-handle-delete-frame)
>   (advice-add 'save-buffers-kill-terminal :override 
>      #'nick-save-buffers-kill-terminal)
> 
> This uses applescript to hide the last frame instead of closing it. The
> OS takes care of the unhiding when you click on the dock icon, relaunch
> the app, double click a file, etc. Do Emacs > Quit Emacs or `kill-emacs'
> to exit.
> 
> It doesn't leave the emacs menubar visible after a frame is closed, but
> I've not found that to be a problem in practice. 
> 
> If you don't use the mac-port you can probably do the same thing by
> dropping in ns-do-applescript, although I haven't tried it. 
> 
> Nick
> 




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Mac: Don't quit Emacs when window is closed
  2016-01-19 18:35   ` Luis Gerhorst
@ 2016-01-19 21:46     ` Luis Gerhorst
  2016-01-19 22:04     ` Nick Helm
  1 sibling, 0 replies; 15+ messages in thread
From: Luis Gerhorst @ 2016-01-19 21:46 UTC (permalink / raw)
  To: help-gnu-emacs

I now found a solution that works pretty neat

;; Directly copied from frame.el but now hide Emacs instead of killing
;; it when last frame will be closed.
(defun handle-delete-frame-without-kill-emacs (event)
  "Handle delete-frame events from the X server."
  (interactive "e")
  (let ((frame (posn-window (event-start event)))
        (i 0)
        (tail (frame-list)))
    (while tail
      (and (frame-visible-p (car tail))
           (not (eq (car tail) frame))
           (setq i (1+ i)))
      (setq tail (cdr tail)))
    (if (> i 0)
        (delete-frame frame t)
      ;; Not (save-buffers-kill-emacs) but instead:
      (ns-do-hide-emacs))))

(when (eq system-type 'darwin)
  (advice-add 'handle-delete-frame :override
              #'handle-delete-frame-without-kill-emacs))

This code overrides that functions that handles the close-window button and makes it hide Emacs instead of quitting the application when the last Emacs frame is closed. C-x C-c and everything else still works as expected. It's not completely optimal since it doesn't really close the frame and also does not ask you if you want to save any changed buffers (it does however when you kill Emacs).

> On 19.01.2016, at 19:35, Luis Gerhorst <privat@luisgerhorst.de> wrote:
> 
> Thanks! I tried it but it gives me some error in GNU Emacs. For the beginning I instead added this code wich make C-z no longer painful on OS X:
> 
> (when (eq system-type 'darwin)
>  (global-set-key [remap suspend-frame] 'ns-do-hide-emacs))
> 
> Without it the Emacs window minimizes slowly into the dock on my iMac 27" Retina.
> 
>> On 18.01.2016, at 08:15, Nick Helm <nick@tenpoint.co.nz> wrote:
>> 
>> 
>>> I have the problem that I always quit Emacs by mistake when I am done
>>> with a task by clicking the button to close the Emacs window. I have a
>>> few ideas / questions:
>>> 
>>> - Wouldn't it be a good idea to make Emacs act like most Mac
>>> application and not quit the application when the window is closed? Is
>>> there some reason why this is not possible?
>>> - How can I disable the button to close the window or make it call
>>> suspend-frame instead of save-buffers-kill-emacs?
>> 
>> I wanted to do something similar on my mac-port emacs a while back and
>> added this to my init.el:
>> 
>>  (defun nick-mac-hide-last-frame (orig-fun &rest args)
>>     "Check if last visible frame is being closed and hide it instead."
>>     (if (and (featurep 'mac)
>>              (display-graphic-p nil)
>>              (= 1 (length (frame-list)))) (progn 
>>        (when (eq (frame-parameter (selected-frame) 'fullscreen) 'fullscreen)
>>           (set-frame-parameter (selected-frame) 'fullscreen nil) 
>>           (sit-for 1.2))
>>        (mac-do-applescript "tell application \"System Events\" \
>>           to tell process \"Emacs\" to set visible to false")
>>        (sit-for 1.5)
>>        (modify-frame-parameters (selected-frame) default-frame-alist)
>>        (delete-other-windows)
>>        (switch-to-buffer "*scratch*"))
>>       (apply orig-fun args)))
>> 
>>  (defun nick-handle-delete-frame (event)
>>     "Hide last visible frame when clicking frame close button."
>>     (interactive "e")
>>     (let ((frame (posn-window (event-start event))))
>>        (delete-frame frame t)))
>> 
>>  (defun nick-save-buffers-kill-terminal (&optional arg)
>>     "Hide last visible frame instead of closing Emacs."
>>     (interactive "P")
>>     (delete-frame (selected-frame) t))
>> 
>>  (advice-add 'delete-frame :around #'nick-mac-hide-last-frame)
>>  (advice-add 'handle-delete-frame :override #'nick-handle-delete-frame)
>>  (advice-add 'save-buffers-kill-terminal :override 
>>     #'nick-save-buffers-kill-terminal)
>> 
>> This uses applescript to hide the last frame instead of closing it. The
>> OS takes care of the unhiding when you click on the dock icon, relaunch
>> the app, double click a file, etc. Do Emacs > Quit Emacs or `kill-emacs'
>> to exit.
>> 
>> It doesn't leave the emacs menubar visible after a frame is closed, but
>> I've not found that to be a problem in practice. 
>> 
>> If you don't use the mac-port you can probably do the same thing by
>> dropping in ns-do-applescript, although I haven't tried it. 
>> 
>> Nick
>> 
> 
> 




^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Mac: Don't quit Emacs when window is closed
  2016-01-19 18:35   ` Luis Gerhorst
  2016-01-19 21:46     ` Luis Gerhorst
@ 2016-01-19 22:04     ` Nick Helm
  1 sibling, 0 replies; 15+ messages in thread
From: Nick Helm @ 2016-01-19 22:04 UTC (permalink / raw)
  To: Luis Gerhorst; +Cc: help-gnu-emacs


> Thanks! I tried it but it gives me some error in GNU Emacs. For the
> beginning I instead added this code wich make C-z no longer painful on
> OS X:
>
> (when (eq system-type 'darwin)
>   (global-set-key [remap suspend-frame] 'ns-do-hide-emacs))
>
> Without it the Emacs window minimizes slowly into the dock on my iMac
> 27" Retina.

On OSX emacs, `suspend-frame' is the equivalent of clicking the yellow
minimise button on the window decoration. This is normally on C-z. You
could try using s-h (super-h) instead, which is pre-mapped to
`ns-do-hide-emacs' and should give you a quick hide key if that's what
you need.

Sorry about the error on GNU/Emacs. Try replacing the first function
with this instead:

   (defun nh-mac-hide-last-frame (orig-fun &rest args)
      "Check if last visible frame is being closed and hide it instead."
      (if (and (featurep 'ns)
               (display-graphic-p nil)
               (= 1 (length (frame-list)))) (progn 
         (when (eq (frame-parameter (selected-frame) 'fullscreen) 'fullboth)
            (set-frame-parameter (selected-frame) 'fullscreen nil) 
            (sit-for 1.2))
         (ns-hide-emacs t)
         (sit-for 1.5)
         (modify-frame-parameters (selected-frame) default-frame-alist)
         (delete-other-windows)
         (switch-to-buffer "*scratch*"))
        (apply orig-fun args)))

This just replaces the mac-* functions with ns-* equivalents. Having
access to `ns-hide-emacs' and `ns-do-hide-emacs' is much nicer than
messing about with applescript imho.

One more thing, if you'd like the frame reset to work (so the unhidden
frame has the same position and size properties as a new frame), make
sure you have default-frame-alist defined in your init.el. Even better is
to set the frame parameters in ~/Library/Preferences/org.gnu.emacs.plist
to avoid that annoying flicker as the frame resizes during startup. 

Nick



^ permalink raw reply	[flat|nested] 15+ messages in thread

* repeating a search a certain number of times
  2016-01-18 17:05     ` Barry Margolin
  2016-01-18 18:03       ` Philipp Stephani
@ 2016-01-21 17:36       ` Timur Aydin
  2016-01-21 18:10         ` Drew Adams
  1 sibling, 1 reply; 15+ messages in thread
From: Timur Aydin @ 2016-01-21 17:36 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I have been looking for a way to repeat a search a certain number of 
times, and from the documentation i have found the search-forward 
function to do that:

(search-forward "something" nil nil 5)

But unfortunately this isn't bound to a key. The docstring says it is 
bound to <find>, but I don't know what that means. It isn't a lisp 
function. I thought maybe it is a menu item, but can't see that in the 
menu either.

So my question is, how can I bind this to a key so that when I press it, 
it asks me for the string, then the repetition count and then goes ahead 
and finds it?

-- 
Timur



^ permalink raw reply	[flat|nested] 15+ messages in thread

* repeating a search a certain number of times
@ 2016-01-21 17:41 Timur Aydin
  2016-01-21 22:14 ` Marcin Borkowski
  0 siblings, 1 reply; 15+ messages in thread
From: Timur Aydin @ 2016-01-21 17:41 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I have been looking for a way to repeat a search a certain number of 
times, and from the documentation i have found the search-forward 
function to do that:

(search-forward "something" nil nil 5)

But unfortunately this isn't bound to a key. The docstring says it is 
bound to <find>, but I don't know what that means. It isn't a lisp 
function. I thought maybe it is a menu item, but can't see that in the 
menu either.

So my question is, how can I bind this to a key so that when I press it, 
it asks me for the string, then the repetition count and then goes ahead 
and finds it?

-- 
Timur



^ permalink raw reply	[flat|nested] 15+ messages in thread

* RE: repeating a search a certain number of times
  2016-01-21 17:36       ` repeating a search a certain number of times Timur Aydin
@ 2016-01-21 18:10         ` Drew Adams
  0 siblings, 0 replies; 15+ messages in thread
From: Drew Adams @ 2016-01-21 18:10 UTC (permalink / raw)
  To: Timur Aydin, help-gnu-emacs

> I have been looking for a way to repeat a search a certain number of
> times, and from the documentation i have found the search-forward
> function to do that:
> 
> (search-forward "something" nil nil 5)
> 
> But unfortunately this isn't bound to a key. The docstring says it is
> bound to <find>, but I don't know what that means. It isn't a lisp
> function. I thought maybe it is a menu item, but can't see that in the
> menu either.
> 
> So my question is, how can I bind this to a key so that when I press it,
> it asks me for the string, then the repetition count and then goes ahead
> and finds it?

`search-forward' is bound to `C-s RET'. Just repeat `C-s RET' to repeat
your search (no need to enter the same input again).

See the Emacs manual, node `Nonincremental Search': `C-h r g noni TAB RET'.

Is there some reason you do not want to use incremental search: `C-s'?
If you do that, then just repeat `C-s'.

See the Emacs manual, node `Incremental Search': `C-h r g incr TAB RET'.



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: repeating a search a certain number of times
  2016-01-21 17:41 repeating a search a certain number of times Timur Aydin
@ 2016-01-21 22:14 ` Marcin Borkowski
  0 siblings, 0 replies; 15+ messages in thread
From: Marcin Borkowski @ 2016-01-21 22:14 UTC (permalink / raw)
  To: Timur Aydin; +Cc: help-gnu-emacs


On 2016-01-21, at 18:41, Timur Aydin <ta@taydin.org> wrote:

> Hello,
>
> I have been looking for a way to repeat a search a certain number of 
> times, and from the documentation i have found the search-forward 
> function to do that:
>
> (search-forward "something" nil nil 5)
>
> But unfortunately this isn't bound to a key. The docstring says it is 
> bound to <find>, but I don't know what that means. It isn't a lisp 
> function. I thought maybe it is a menu item, but can't see that in the 
> menu either.
>
> So my question is, how can I bind this to a key so that when I press it, 
> it asks me for the string, then the repetition count and then goes ahead 
> and finds it?

Others will probably chime in, and I don't have the time to write that
function for you, but you might want to read these sections in the Elisp
reference:

(info "(emacs)Rebinding")
(info "(elisp)Using interactive")

(If you're reading this message in Emacs, place the point after any of
the above expressions, and press C-x C-e.)

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] 15+ messages in thread

end of thread, other threads:[~2016-01-21 22:14 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-17 20:07 Mac: Don't quit Emacs when window is closed Luis Gerhorst
2016-01-17 22:40 ` Marcin Borkowski
2016-01-18  4:21   ` Random832
2016-01-19 18:31     ` Luis Gerhorst
     [not found]   ` <mailman.2484.1453090928.843.help-gnu-emacs@gnu.org>
2016-01-18 17:05     ` Barry Margolin
2016-01-18 18:03       ` Philipp Stephani
2016-01-21 17:36       ` repeating a search a certain number of times Timur Aydin
2016-01-21 18:10         ` Drew Adams
2016-01-18  7:15 ` Mac: Don't quit Emacs when window is closed Nick Helm
2016-01-19 18:35   ` Luis Gerhorst
2016-01-19 21:46     ` Luis Gerhorst
2016-01-19 22:04     ` Nick Helm
2016-01-18  9:11 ` tomas
  -- strict thread matches above, loose matches on Subject: below --
2016-01-21 17:41 repeating a search a certain number of times Timur Aydin
2016-01-21 22:14 ` Marcin Borkowski

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).