From: Xebar Saram <zeltakc@gmail.com>
To: Thorsten Jolitz <tjolitz@gmail.com>
Cc: org mode <emacs-orgmode@gnu.org>
Subject: Re: a quick way to switch orgmode notes between read-only/editing?
Date: Fri, 18 Jul 2014 18:31:32 +0300 [thread overview]
Message-ID: <CAOQHXPpSe0koR3kL_8a9A=-vFnpqVGpeFsd20kTHf8my3-v50A@mail.gmail.com> (raw)
In-Reply-To: <87vbqusv2q.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4497 bytes --]
Thx again Thorsten
for some reason it wont work here. i evaluated it and have in in my config.
i open notes in view mode (the other hook i used) and then edit them. i
leave the pc for 5-10 minutes but it dosent revert to view mode for some
reason. am i missing something?
thx!
Z
On Fri, Jul 18, 2014 at 3:35 PM, Thorsten Jolitz <tjolitz@gmail.com> wrote:
> Xebar Saram <zeltakc@gmail.com> writes:
>
> > Thx Thorsten
> >
> > i tried that but that dosent seem to work :) any way i can try to
> > debug this (i apologize in advance for my zero lisp knowledge :)
>
> it actually worked, but only with calling the reset function manually
> once.
>
> try this:
>
> #+begin_src emacs-lisp
> (defvar tj/last-buffer-tick nil)
> (make-variable-buffer-local 'tj/last-buffer-tick)
>
> (defun tj/new-buffer-ticks-p ()
> (let ((curr-tick (buffer-modified-tick))
> (last-tick tj/last-buffer-tick))
> (setq tj/last-buffer-tick curr-tick)
> (and last-tick (< last-tick curr-tick))))
>
> (defun tj/reset-view-mode ()
> (run-with-timer 0 (* 5 60)
> (lambda ()
> (when (tj/new-buffer-ticks-p)
> (view-mode t)))))
>
> (add-hook 'org-mode-hook 'tj/reset-view-mode)
> #+end_src
>
> > On Fri, Jul 18, 2014 at 11:54 AM, Thorsten Jolitz <tjolitz@gmail.com>
> > wrote:
> >
> > Xebar Saram <zeltakc@gmail.com> writes:
> >
> > > Thx again all, really cool.
> > >
> > > one last question. anyone mind pasting code to revert an open
> > buffer
> > > to read only when idle for lets say 5 minutes?
> >
> >
> > you could try this (untested!):
> >
> > #+begin_src emacs-lisp
> > (defvar tj/last-buffer-tick nil)
> > (make-variable-buffer-local 'tj/last-buffer-tick)
> >
> > (add-hook 'org-mode-hook
> > (lambda ()
> > (setq tj/last-buffer-tick (buffer-modified-tick))))
> >
> > (defun tj/new-buffer-ticks-p ()
> > (let ((curr-tick (buffer-modified-tick))
> > (last-tick tj/last-buffer-tick))
> > (setq tj/last-buffer-tick curr-tick)
> > (< last-tick curr-tick)))
> >
> > (defun tj/reset-view-mode ()
> > (run-with-timer (* 5 60) (* 5 60)
> > (lambda ()
> > (when (tj/new-buffer-ticks-p)
> > (view-mode t)))))
> > #+end_src
> >
> >
> >
> >
> > > On Fri, Jul 18, 2014 at 2:42 AM, Eric Abrahamsen
> > > <eric@ericabrahamsen.net> wrote:
> > >
> > > Xebar Saram <zeltakc@gmail.com> writes:
> > >
> > > > Thanks guys. really appreciate all your help
> > > >
> > > > im now using view-mode with hooks as suggested. btw whats the
> > > > advantages of viewer-mode over read-only-mode
> > >
> > >
> > > Mostly that you get more convenient navigation commands.
> > Scrolling
> > > and
> > > searching etc don't require control modifiers, and it becomes a
> > > bit
> > > easier to move around files.
> > >
> > >
> > >
> > > > best
> > > >
> > > > Z
> > > >
> > > >
> > > > On Thu, Jul 17, 2014 at 5:46 PM, Jorge A. Alfaro-Murillo <
> > > > jorge.a.alfaro@gmail.com> wrote:
> > > >
> > > > Xebar Saram <zeltakc@gmail.com> writes:
> > > >
> > > > > i keep once and a while screwing up my notes with unintended
> > > > editing
> > > > > (erroneous key presses etc) and was wondering if any one
> > knew
> > > > of a way
> > > > > to to switch orgmode notes between read-only/editing?
> > > >
> > > > Hi Xebar. Use C-x C-q. This works for every file, I use it in
> > > > particular
> > > > for notes that I do not want to edit.
> > > >
> > > > It runs the command read-only-mode which changes whether the
> > > > current
> > > > buffer is read-only. Actually the command switches the local
> > > > variable
> > > > buffer-read-only, so you can use that variable as local for
> > > every
> > > > file
> > > > that you do not want to edit by default. At the end of those
> > > > files add:
> > > >
> > > > #+BEGIN_EXAMPLE
> > > > %%% Local Variables:
> > > > %%% buffer-read-only: t
> > > > %%% End:
> > > > #+END_EXAMPLE
> > > >
> > > > And every time that you want to edit them just do C-x C-q
> > > >
> > > > Best,
> > > >
> > > > Jorge.
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > --
> > cheers,
> > Thorsten
> >
> >
> >
> >
>
> --
> cheers,
> Thorsten
>
>
>
[-- Attachment #2: Type: text/html, Size: 6831 bytes --]
next prev parent reply other threads:[~2014-07-18 15:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-17 12:40 a quick way to switch orgmode notes between read-only/editing? Xebar Saram
2014-07-17 13:13 ` Thorsten Jolitz
2014-07-17 13:22 ` Xebar Saram
2014-07-17 13:23 ` Xebar Saram
2014-07-17 13:50 ` Thorsten Jolitz
2014-07-17 13:53 ` Nick Dokos
2014-07-17 13:57 ` Thorsten Jolitz
2014-07-17 14:46 ` Jorge A. Alfaro-Murillo
2014-07-17 15:15 ` Xebar Saram
2014-07-17 23:42 ` Eric Abrahamsen
2014-07-18 7:50 ` Xebar Saram
2014-07-18 8:54 ` Thorsten Jolitz
2014-07-18 12:14 ` Xebar Saram
2014-07-18 12:35 ` Thorsten Jolitz
2014-07-18 15:31 ` Xebar Saram [this message]
2014-07-18 20:37 ` Thorsten Jolitz
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOQHXPpSe0koR3kL_8a9A=-vFnpqVGpeFsd20kTHf8my3-v50A@mail.gmail.com' \
--to=zeltakc@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=tjolitz@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).