all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Basic emacs lisp question
Date: Tue, 09 Sep 2014 23:05:50 +0200	[thread overview]
Message-ID: <87mwa8y05t.fsf@gmail.com> (raw)
In-Reply-To: 87sik0y3jz.fsf@gmail.com

Thorsten Jolitz <tjolitz@gmail.com> writes:

> Ken <kensubuntu@gmail.com> writes:
>
>> I want to capture whatever is at point in a file into a variable
>> something like the following, but it doesn't seem to work. Can any one
>> suggest what I an doing wrong. It is probably a silly mistake I am
>> unable to see. I am just learning Emacs lisp.
>>
>> (defun process-diary-file ()
>>   "Perform some manipulation of the diary file"
>>   (interactive)
>>   (find-file "~/diary")
>>   (goto-char 1)
>>   (set a (thing-at-point))
>>   (message a))
>
> try
>
> #+BEGIN_SRC emacs-lisp
> (defun process-diary-file ()
>   "Perform some manipulation of the diary file"
>   (interactive)
>   (find-file (expand-file-name "~/diary"))
>   (goto-char (point-min))
>   (setq a (thing-at-point))
>   (message "%s" a))
> #+END_SRC

that was untested and has room for improvement (as mentioned in this
thread).
This is untested again, but hopefully better ;)

#+BEGIN_SRC emacs-lisp
  (defun process-diary-file ()
    "Perform some manipulation of the diary file"
    (interactive)
    (let (a)
      (find-file (expand-file-name "~/diary"))
      (goto-char (point-min))
      (setq a (thing-at-point 'symbol))   
      (message "%s" a)))
#+END_SRC

see 

,----[ C-h f thing-at-point RET ]
| thing-at-point is an autoloaded compiled Lisp function in
| `thingatpt.el'.
| 
| (thing-at-point THING)
| 
| Return the THING at point.
| THING should be a symbol specifying a type of syntactic entity.
| Possibilities include `symbol', `list', `sexp', `defun',
| `filename', `url', `email', `word', `sentence', `whitespace',
| `line', `number', and `page'.
| 
| See the file `thingatpt.el' for documentation on how to define
| a symbol as a valid THING.
| 
| [back]
`----


-- 
cheers,
Thorsten




  reply	other threads:[~2014-09-09 21:05 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09 19:35 Basic emacs lisp question Ken
2014-09-09 19:52 ` Thorsten Jolitz
2014-09-09 21:05   ` Thorsten Jolitz [this message]
     [not found]   ` <mailman.8562.1410296811.1147.help-gnu-emacs@gnu.org>
2014-09-09 23:02     ` Emanuel Berg
     [not found] ` <mailman.8561.1410292382.1147.help-gnu-emacs@gnu.org>
2014-09-09 20:07   ` Emanuel Berg
     [not found]     ` <874mwgv93m.fsf@gmail.com>
2014-09-09 20:44       ` Emanuel Berg
     [not found]         ` <87y4tsts4t.fsf@gmail.com>
2014-09-09 22:31           ` Emanuel Berg
2014-09-10  0:49             ` Robert Thorpe
2014-09-10  1:21             ` Ken
2014-09-10  6:00               ` Glyn Millington
2014-09-10 14:31                 ` Ken
2014-09-10 13:12 ` Phillip Lord
2014-09-10 14:06   ` Thien-Thi Nguyen
2014-09-10 14:26   ` Stefan Monnier
2014-09-10 15:45     ` Phillip Lord
2014-09-10 16:59       ` Stefan Monnier
2014-09-11 11:10         ` Phillip Lord
2014-09-11 11:10         ` Phillip Lord
     [not found]   ` <mailman.8619.1410357764.1147.help-gnu-emacs@gnu.org>
2014-09-10 21:39     ` Emanuel Berg
  -- strict thread matches above, loose matches on Subject: below --
2008-04-29 15:49 Basic Emacs Lisp question Matthias Pfeifer
2008-04-29 17:56 ` Giorgos Keramidas
2008-04-30  1:21   ` Giorgos Keramidas
2008-04-30  8:37     ` Tim X
2008-04-30 15:26   ` David Kastrup
2008-04-30 18:36     ` Giorgos Keramidas
2008-05-01  9:25       ` Johan Bockgård
2008-04-29 21:14 ` tyler
2008-04-30  8:31   ` Tim X
2008-05-05 13:38     ` tyler

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=87mwa8y05t.fsf@gmail.com \
    --to=tjolitz@gmail.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.