From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: using flet to suppress meta generation in html export? Date: Tue, 06 Nov 2018 15:35:53 +0000 Message-ID: <87a7mm2p7q.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gK3Oc-0008Km-QK for emacs-orgmode@gnu.org; Tue, 06 Nov 2018 10:36:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gK3OX-0005QD-Vu for emacs-orgmode@gnu.org; Tue, 06 Nov 2018 10:36:02 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:40091) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gK3OX-0005Or-LH for emacs-orgmode@gnu.org; Tue, 06 Nov 2018 10:35:57 -0500 Received: by mail-wm1-x334.google.com with SMTP id b203-v6so12453021wme.5 for ; Tue, 06 Nov 2018 07:35:57 -0800 (PST) In-Reply-To: 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@gnu.org Sender: "Emacs-orgmode" To: Matt Price , Org Mode Hi Matt, 2018ko azaroak 6an, Matt Price-ek idatzi zuen: >=20 > Hi, >=20 > I was writing a function to quickly post the ocntents of subtrees to the > Canvas Learning Management System. I was trying to strip down the export= ed > HTML to an absolute minimum and had forgotten about the body-only paramter > to org-export-as (!!). So, my solution was to try to rebind > 'org-html--build-meta-info to always just return "". However, I can't > seem to do it properly and I'm wondering if someone can help me figure out > what's wrong. It's my first time using cl-flet! And I know there are > various approaches, but I odn't understnad whyt this is notworking, when > for instance, this does work for me: >=20 > (cl-flet ((+ > (lambda (&rest args) (message "no plus!")))) > (+ "whoops")) > ;; "no plus!" >=20 > Meanwhile, here's my non-functional code: Quoting from the info page (info "(cl) Function Bindings"): The bindings are lexical in scope. This means that all references to the named functions must appear physically within FORMS. I believe that you can accomplish what you are trying to do with: (cl-letf (((symbol-function 'org-html--build-meta-info) (lambda (&rest args) ""))) your-code-here) You could also do something like: (let ((my-advice (lambda (&rest _) ""))) (advice-add 'org-html--build-meta-info :override my-advice) (unwind-protect (progn your-code-here) (advice-remove 'org-html--build-meta-info my-advice))) (Why do I think this is better, despite being more verbose? Advice-add is specifically designed to change the binding of functions at runtime, and so it does some specialized things that cl-letf doesn=CA=BCt do. This = in turn means that it should be a more robust way of accomplishing the desired outcome.) --=20 Aaron Ecay