From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sebastien Vauban" Subject: Re: [Sticky Agenda] How to create Agenda Buffers in functions Date: Thu, 19 Apr 2012 22:17:08 +0200 Message-ID: <80obqn79yz.fsf@somewhere.org> References: <87fwckbv21.fsf@gmx.ch> <87limc73av.wl%max@openchat.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hi Max, Max Mikhanosha wrote: > Sven Bretfeld wrote: >> The Sticky Agenda is something I have been waiting for since a long >> time. Thank you very much! Let me thank you for the sticky agenda as well. I can't say I'm using multi= ple agendas in parallel -- while I'll surely make more use of it --, but the fa= ct that the agenda view comes almost instataneously is really great! >> I want to write a function that creates a new frame with several >> windows, each displaying a different Agenda Views. I fail to find a >> function that creates special agenda views. Formerly I used >> org-batch-agenda for similar purposes. But that doesn't work in the >> sticky branch. This is what I have: >>=20 >> (defun my-gtd-frame () >> (interactive) >> (save-excursion) >> (make-frame '( >> (name . "gtd") >> (active-alpha . 0.75) >> (inactive-alpha . 0.8) >> (top . 110)=20 >> (left . 2000)=20 >> (width . 80)=20 >> (height . 40) >> (font . "-Adobe-Courier-Medium-R-Normal--18-180-75-75-M-110-ISO8859= -1"))) >> (select-frame-by-name "gtd") >> (toggle-fullscreen) >> (org-agenda-goto-today) >> (delete-other-windows) >> (split-window-horizontally) >> (other-window 1) >> (org-batch-agenda "OFFICE/NEXT") >> ) > > This is the same bug as Martyn Jago reported earlier, basically I > forgot that separate org agenda commands can be run individually > rather then through (org-agenda) function. > > A temporary workaround in your specific case would be to wrap > (org-batch-agenda) call like this: > > (catch 'exit > (org-batch-agenda "OFFICE/NEXT")) > > I tested it and it seems to work.. The actual fix for the bug will be > similar and will be wrapping bodies of (org-todo-list) (org-tags-list) > and friends with (catch 'exit), but it needs to be done conditionally > as to only do it its called individually and not from (org-agenda) I tried the updated version of Sven: #+begin_src emacs-lisp (defun my-gtd-frame () (interactive) (save-excursion) (make-frame '( (name . "gtd") (active-alpha . 0.75) (inactive-alpha . 0.8) (top . 20) (left . 20) (width . 80) (height . 40))) (select-frame-by-name "gtd") (org-agenda-goto-today) (delete-other-windows) (split-window-horizontally) (other-window 1) (catch 'exit (org-batch-agenda "work"))) #+end_src But I get the following error: --8<---------------cut here---------------start------------->8--- Debugger entered--Lisp error: (error "Not allowed in nil-type agenda buffer= s") signal(error ("Not allowed in nil-type agenda buffers")) error("Not allowed in %s-type agenda buffers" nil) (if error (error "Not allowed in %s-type agenda buffers" org-agenda-type)= nil) (if (memq org-agenda-type types) t (if error (error "Not allowed in %s-ty= pe agenda buffers" org-agenda-type) nil)) org-agenda-check-type(t timeline agenda) org-agenda-goto-today() my-gtd-frame() call-interactively(my-gtd-frame) (let* ((command (helm-comp-read "M-x " obarray :test (quote commandp) :re= quires-pattern helm-M-x-requires-pattern :name "Emacs Commands" :buffer "*h= elm M-x*" :persistent-action (quote pers-help) :persistent-help "Describe t= his command" :history history :must-match t :candidates-in-buffer t :fc-tra= nsformer (quote helm-M-x-transformer))) (sym-com (intern command))) (unless= current-prefix-arg (setq current-prefix-arg helm-current-prefix-arg)) (set= q this-command sym-com) (call-interactively sym-com) (setq extended-command= -history (cons command (delete command history)))) (progn (fset (quote pers-help) (function* (lambda (candidate) (block pers= -help (let ((hbuf ...)) (if (and in-help ...) (progn ... ...) (set-window-d= edicated-p ... nil) (describe-function ...) (message nil) (setq in-help t))= (setq help-cand candidate)))))) (let* ((command (helm-comp-read "M-x " oba= rray :test (quote commandp) :requires-pattern helm-M-x-requires-pattern :na= me "Emacs Commands" :buffer "*helm M-x*" :persistent-action (quote pers-hel= p) :persistent-help "Describe this command" :history history :must-match t = :candidates-in-buffer t :fc-transformer (quote helm-M-x-transformer))) (sym= -com (intern command))) (unless current-prefix-arg (setq current-prefix-arg= helm-current-prefix-arg)) (setq this-command sym-com) (call-interactively = sym-com) (setq extended-command-history (cons command (delete command histo= ry))))) (unwind-protect (progn (fset (quote pers-help) (function* (lambda (candid= ate) (block pers-help (let (...) (if ... ... ... ... ... ...) (setq help-ca= nd candidate)))))) (let* ((command (helm-comp-read "M-x " obarray :test (qu= ote commandp) :requires-pattern helm-M-x-requires-pattern :name "Emacs Comm= ands" :buffer "*helm M-x*" :persistent-action (quote pers-help) :persistent= -help "Describe this command" :history history :must-match t :candidates-in= -buffer t :fc-transformer (quote helm-M-x-transformer))) (sym-com (intern c= ommand))) (unless current-prefix-arg (setq current-prefix-arg helm-current-= prefix-arg)) (setq this-command sym-com) (call-interactively sym-com) (setq= extended-command-history (cons command (delete command history))))) (if --= cl-letf-bound-- (fset (quote pers-help) --cl-letf-save--) (fmakunbound (quo= te pers-help)))) (let* ((--cl-letf-bound-- (fboundp (quote pers-help))) (--cl-letf-save-- = (and --cl-letf-bound-- (symbol-function (quote pers-help))))) (unwind-prote= ct (progn (fset (quote pers-help) (function* (lambda (candidate) (block per= s-help (let ... ... ...))))) (let* ((command (helm-comp-read "M-x " obarray= :test (quote commandp) :requires-pattern helm-M-x-requires-pattern :name "= Emacs Commands" :buffer "*helm M-x*" :persistent-action (quote pers-help) := persistent-help "Describe this command" :history history :must-match t :can= didates-in-buffer t :fc-transformer (quote helm-M-x-transformer))) (sym-com= (intern command))) (unless current-prefix-arg (setq current-prefix-arg hel= m-current-prefix-arg)) (setq this-command sym-com) (call-interactively sym-= com) (setq extended-command-history (cons command (delete command history))= ))) (if --cl-letf-bound-- (fset (quote pers-help) --cl-letf-save--) (fmakun= bound (quote pers-help))))) (letf (((symbol-function (quote pers-help)) (function* (lambda (candidate= ) (block pers-help (let (...) (if ... ... ... ... ... ...) (setq help-cand = candidate))))))) (let* ((command (helm-comp-read "M-x " obarray :test (quot= e commandp) :requires-pattern helm-M-x-requires-pattern :name "Emacs Comman= ds" :buffer "*helm M-x*" :persistent-action (quote pers-help) :persistent-h= elp "Describe this command" :history history :must-match t :candidates-in-b= uffer t :fc-transformer (quote helm-M-x-transformer))) (sym-com (intern com= mand))) (unless current-prefix-arg (setq current-prefix-arg helm-current-pr= efix-arg)) (setq this-command sym-com) (call-interactively sym-com) (setq e= xtended-command-history (cons command (delete command history))))) (letf* (((symbol-function (quote pers-help)) (function* (lambda (candidat= e) (block pers-help (let (...) (if ... ... ... ... ... ...) (setq help-cand= candidate))))))) (let* ((command (helm-comp-read "M-x " obarray :test (quo= te commandp) :requires-pattern helm-M-x-requires-pattern :name "Emacs Comma= nds" :buffer "*helm M-x*" :persistent-action (quote pers-help) :persistent-= help "Describe this command" :history history :must-match t :candidates-in-= buffer t :fc-transformer (quote helm-M-x-transformer))) (sym-com (intern co= mmand))) (unless current-prefix-arg (setq current-prefix-arg helm-current-p= refix-arg)) (setq this-command sym-com) (call-interactively sym-com) (setq = extended-command-history (cons command (delete command history))))) (flet ((pers-help (candidate) (let ((hbuf (get-buffer (help-buffer)))) (i= f (and in-help (string=3D candidate help-cand)) (progn (unless (equal hbuf = helm-current-buffer) (kill-buffer hbuf)) (setq in-help nil)) (set-window-de= dicated-p (get-buffer-window helm-current-buffer) nil) (describe-function (= intern candidate)) (message nil) (setq in-help t)) (setq help-cand candidat= e)))) (let* ((command (helm-comp-read "M-x " obarray :test (quote commandp)= :requires-pattern helm-M-x-requires-pattern :name "Emacs Commands" :buffer= "*helm M-x*" :persistent-action (quote pers-help) :persistent-help "Descri= be this command" :history history :must-match t :candidates-in-buffer t :fc= -transformer (quote helm-M-x-transformer))) (sym-com (intern command))) (un= less current-prefix-arg (setq current-prefix-arg helm-current-prefix-arg)) = (setq this-command sym-com) (call-interactively sym-com) (setq extended-com= mand-history (cons command (delete command history))))) (let* (in-help help-cand special-display-buffer-names special-display-reg= exps helm-persistent-action-use-special-display (history (loop with hist fo= r i in extended-command-history for com =3D (intern i) when (fboundp com) c= ollect i into hist finally return hist))) (flet ((pers-help (candidate) (le= t ((hbuf (get-buffer ...))) (if (and in-help (string=3D candidate help-cand= )) (progn (unless ... ...) (setq in-help nil)) (set-window-dedicated-p (get= -buffer-window helm-current-buffer) nil) (describe-function (intern candida= te)) (message nil) (setq in-help t)) (setq help-cand candidate)))) (let* ((= command (helm-comp-read "M-x " obarray :test (quote commandp) :requires-pat= tern helm-M-x-requires-pattern :name "Emacs Commands" :buffer "*helm M-x*" = :persistent-action (quote pers-help) :persistent-help "Describe this comman= d" :history history :must-match t :candidates-in-buffer t :fc-transformer (= quote helm-M-x-transformer))) (sym-com (intern command))) (unless current-p= refix-arg (setq current-prefix-arg helm-current-prefix-arg)) (setq this-com= mand sym-com) (call-interactively sym-com) (setq extended-command-history (= cons command (delete command history)))))) helm-M-x() call-interactively(helm-M-x nil nil) --8<---------------cut here---------------end--------------->8--- Am I missing something? Best regards, Seb --=20 Sebastien Vauban