all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to return to the position from where I did tags-query-replace?
Date: Sun, 04 Feb 2018 05:30:11 +0100	[thread overview]
Message-ID: <86y3k9wf58.fsf@zoho.com> (raw)
In-Reply-To: 86d11lxwl9.fsf@zoho.com

Boy, advices are sure difficult to use, even
for people who do not know how to use them!

But this seems to work (?). The original
function I wrote, actually didn't require any
modification, just the extra advice call to
glue it together.

I wrote a couple of pretty meaningless random
functions, no pun intended, just for testing.
Those are the ones one should replace with the
real thing, if one would like to do this
for real.

(defun do-whatever-return (fun &rest args)
  (let ((point  (point))
        (buffer (current-buffer)) )
    (apply fun args)
    (when (bufferp buffer)
      (switch-to-buffer buffer)
      (goto-char (point) ))))
;; (do-whatever-return #'switch-to-buffer "*Help*")

(defun switch-buffer-random ()
  (let*((buffers      (buffer-list))
        (num-bufs     (length buffers))
        (rand-buf-num (random (1- num-bufs)))
        (buf          (nth rand-buf-num buffers)) )
    (when (bufferp buf) (switch-to-buffer buf)) ))
;; (switch-buffer-random)

(defun move-point-random ()
  (let*((min (point-min))
        (max (point-max))
        (random-char (+ min (random (- max min))))
        (new-char (goto-char random-char)) )
    (message "New point in %s is %d" (current-buffer) (point))
    ))
;; (move-point-random)

(defun switch-buffer-move-point-random ()
  (switch-buffer-random)
  (move-point-random) )
;; (switch-buffer-move-point-random)

;; (advice-add 'switch-buffer-move-point-random :around #'do-whatever-return)
;; (switch-buffer-move-point-random)

-- 
underground experts united
http://user.it.uu.se/~embe8573


  reply	other threads:[~2018-02-04  4:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-05 18:33 How to return to the position from where I did tags-query-replace? Yevgeniy Makarov
2007-09-05 21:41 ` Eric Hanchrow
     [not found] ` <mailman.388.1189029337.18990.help-gnu-emacs@gnu.org>
2018-02-03 22:27   ` Ambrose Laing
2018-02-04  3:28     ` Emanuel Berg
2018-02-04  4:30       ` Emanuel Berg [this message]
2018-02-04  4:34         ` Emanuel Berg
2018-02-04  4:46         ` Emanuel Berg
2018-02-04 20:14           ` aklaing
2018-02-04 20:25             ` Emanuel Berg
2018-02-04 20:36               ` Emanuel Berg
2018-02-04 20:37               ` aklaing
2018-02-04 20:41                 ` Emanuel Berg
2018-02-04 20:52                   ` aklaing
2018-02-04 21:02                     ` Emanuel Berg
2018-02-04 20:29             ` aklaing
2018-02-04 20:38               ` Emanuel Berg

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=86y3k9wf58.fsf@zoho.com \
    --to=moasen@zoho.com \
    --cc=help-gnu-emacs@gnu.org \
    /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.