From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 2WiyC6byFmHIDAEAgWs5BA (envelope-from ) for ; Sat, 14 Aug 2021 00:31:02 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id wGnUBqbyFmE8RAAA1q6Kng (envelope-from ) for ; Fri, 13 Aug 2021 22:31:02 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9ABB116F3C for ; Sat, 14 Aug 2021 00:31:01 +0200 (CEST) Received: from localhost ([::1]:53552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEfhc-0001mp-Ls for larch@yhetil.org; Fri, 13 Aug 2021 18:31:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEfgw-0001au-Bj for emacs-orgmode@gnu.org; Fri, 13 Aug 2021 18:30:18 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:38536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mEfgv-0004nE-1Y for emacs-orgmode@gnu.org; Fri, 13 Aug 2021 18:30:18 -0400 Received: by mail-pj1-x1033.google.com with SMTP id om1-20020a17090b3a8100b0017941c44ce4so4498597pjb.3 for ; Fri, 13 Aug 2021 15:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=MrYHtxe1Brkco2ZgLHT0KnpgrUoLNuq+1ZcrOwq9UKw=; b=dnEXtNTjbd2ISzyYf5GOjDocISJA48J8mjn3sy9P5IhOUROYyD/8ksk9cOIWEpDc3T vAM99PvjRWB/hwmHD64I4m4HHCv23VWPfjT98ESE2xH/Zu+EXspD9UOY1Ae/buvJeR21 GLqrqfpt9S60WZtHAMd//FgFYQ4QfE7e9A3ky2X6RWEHR376v1Wpf/r+eEGIp8AE+DFj /zjzDfsyP/ORYwNSY4CYsskSCxO5/1IG3UFGCgVsQdF5kAgdYDZU0BjEVGepjknpaUSI oXzmdgRlO4MO4mkFhtkgZ3Wsz+4OslNES77uKgngRLCxQncFdvnJwrzZjb2xEZo4Wu5u GXaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=MrYHtxe1Brkco2ZgLHT0KnpgrUoLNuq+1ZcrOwq9UKw=; b=dIGUWML0k0FIOA9vAaIZBWaei1YNLVEEp5VulGcQZPyQwmd/smjc7kRPE+YlbLrGFE xc4NpMMjHumoAJQrrFm3b13TAB1uWSOpJIHm6mGxiHhUdpNUtwxBppL4dqn5M8Fybucu TetF9e8uML9/eNGvLA+3s8HXU5c3x921AskMv7x68hs1+UI1sJ+XP6vRPJrgyYNVD63W sHSuorcWawBh/UgyUb8gEFj3MZC53fBtAnUhmFZboedOkDELuexYIut5Bq4tKJR33gzf qm9aPQdzKGM5KUWMBZTeOnCcr2X2WOo4vlQohYKjKApL0nA4VmwcSu2m5T4z90A2abyQ L7cA== X-Gm-Message-State: AOAM531DFo+G7zFjSTbx/ci++exMkLTtO4n6lBReQP5sNm1y+Qqt85YG V41vav5k1niu/Nfgh7Tm3cetB1hdTnjG2Q== X-Google-Smtp-Source: ABdhPJxDk/Kf914/2Nh9ZUpbnwqB4C8dITOtrN+44udtCbIEnSzpamKAgce8wW8MtB6vgTLcWt5AQA== X-Received: by 2002:a65:5c84:: with SMTP id a4mr4347323pgt.264.1628893814802; Fri, 13 Aug 2021 15:30:14 -0700 (PDT) Received: from r1 ([190.239.232.245]) by smtp.gmail.com with ESMTPSA id b3sm3355426pfi.179.2021.08.13.15.30.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 15:30:14 -0700 (PDT) From: Rodrigo Morales To: emacs-orgmode@gnu.org Subject: Custom function for killing the thing at point Date: Fri, 13 Aug 2021 17:29:17 -0500 Message-ID: <87im095682.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=moralesrodrigo1100@gmail.com; helo=mail-pj1-x1033.google.com X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1628893861; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=MrYHtxe1Brkco2ZgLHT0KnpgrUoLNuq+1ZcrOwq9UKw=; b=rBexkwbPwNmgDxzL+7QL/LCj/lq+/Zo/bFUEjgnxo5ArDc0sEgWdkEkFBZBh0MBXf199nB 0ZVf5WjJVg5C3lBl0eSxwqU1QiOTTIAEEg2EOQNVBx1wvc993rXRQcc9+jGVQA57y9xApv f/Dem+0kahzY6/bLju90tFtIYClEWbRAb7x6mLSsXILeWIkSSKpECyf3UYmtizUUZS2+e/ bK9BbjajO328FWCBFhLxmUI43Hzo9fgpDl7Qva1Wh97ZrL+TAUrZbl+QFf4cT0GRowuOot 34/y0YCH9j3RAuOG4Dn1ZRYyWllV/WGjJqNdQFwNU12hqwyHRbJAEnyLMFT1Gg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628893861; a=rsa-sha256; cv=none; b=HYOloIN+IKrU6qW54SDB9kUVlscYgCthlhNASfJLt2QB6yN+pLeIxjc6Yvl/AqBLG8CXdc Nm/HPtXhE4Vkb51ba2dn6Fi0OxBBJ3eMpOoq5/pYUkpKW388NBwKWiEfp13SOy9gWkcOl2 3K8fcj7HE1cxJhtq5uBnmF6/3J133PwuelDhHu3ykhl7ST03fZtHvSUpBq8T2oIYEvxt2V 1oj1rcTBzzPBc0Ae/JSqKNxGu5Fc6hq+tT5Wq+4jpjgPe15toLncEZEJNwvTD/EifuSllw lP7zmpa/+64AJim+1iv1v2wPY8x+HJJi6DZKh4lWarzVeZPFwnSbgzLP2IuMNw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=dnEXtNTj; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -3.11 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=dnEXtNTj; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 9ABB116F3C X-Spam-Score: -3.11 X-Migadu-Scanner: scn0.migadu.com X-TUID: siZMI4zNQV6W I just created this function for copying the thing under the cursor (it works for some #+BEGIN blocks and links). I think it would be useful for others, so I'm creating this post for getting feedback on the Elisp code and sharing it to those interested. #+BEGIN_SRC elisp (defun my/org-kill-thing-at-point () "Kill the thing at point. The following things are currently supported - #+BEGIN_SRC <> - #+BEGIN_EXPORT <> - #+BEGIN_EXAMPLE <> - #+BEGIN_COMMENT - Org links (the description is not copied)" (interactive) (let* (content (element (org-element-context)) (type (org-element-type element))) (cond ((or (eq type 'src-block) (eq type 'export-block) (eq type 'example-block) (eq type 'comment-block)) (setq content (plist-get (cadr element) :value))) ((eq type 'link) (setq content (plist-get (cadr element) :raw-link))) (t (error "The element at point couldn't be copied."))) (my/kill-new content))) #+END_SRC #+BEGIN_SRC elisp (define-key org-mode-map (kbd "C-c c") 'my/org-kill-thing-at-point) #+END_SRC