I want to achieve: function bookmark-config-files which takes all the files matching mask "asdasd-*.el" in $user-emacs-directory/els/ (path for example)
I'm achieving now: list of bookmarks named after files, but are pointing on file and place where I executed bookmark-config-files function.
My first approach was to use bookmark-set-name and bookmark-set-filename on a constructed bookmark object, but bookmark-make-record is wrong for that purpose, because creates bookmark at point.
(defun bookmark-config-files ()
(let* (($config-files (directory-files "./" t "^asdasd.*el$")))
(dolist ($config-file $config-files )
(bookmark-set-filename (bookmark-make-record) $config-file))))
Then I turned to an idea to find files and then use bookmark-make-record, then close it, but this function bookmarks current point (where it was evaluated) again, and also such 'find-file' solution far from being efficient.
(defun bookmark-config-files ()
(let* (($config-files (directory-files "./" t "^asdasd.*el$")))
(dolist ($config-file $config-files)
(with-current-buffer (find-file-noselect $config-file)
(bookmark-make-record)
(kill-buffer))
)))
So how can I take set of files from dir and make bookmarks of them?
Related
i will get custom block in a .dwg file from a list of blocks which I will parse programmatically in Java.
You can use the command INSERT with the option ?
cd C:\Program Files\Autodesk\AutoCAD 2016
accoreconsole.exe /i "Sample\Database Connectivity\Floor Plan Sample.dwg"
Command: _INSERT
Enter block name or [?]: ?
Enter block(s) to list <*>:
Defined blocks.
"CHAIR7"
"COMPUTER"
"DESK2"
"DESK3"
"DOOR"
"DR-36"
"DR-69P"
"DR-72P"
"FC15X27A"
"FC42X18D"
"FNPHONE"
"IBMAT"
"KEYBOARD"
"NCL-HL"
"RECTANG"
"RMNUM"
"SOFA2"
User Unnamed
Blocks Blocks
17 0
I am not familiar with Core Console but for listing all block in a DWG file, you need to use LISPs. Something like axBlock from jtbworld . You may also mock around with LISP code and call it via a SCRIPT.
Edit:
Copy and paste following code in Notepad and save it as axBlock.lsp in the root fo your C drive (for instance):
(defun c:axblocks (/ b bn tl)
(vlax-for b (vla-get-blocks
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(if (= (vla-get-islayout b) :vlax-false)
(setq tl (cons (vla-get-name b) tl))
)
)
(reverse tl)
)
I just tweaked jtbworld's code a little bit to make it easier for you.
Now you have your LISP code ready and you only need to load it into AutoCAD. You have couple of options for that:
Use APPLOAD command in AutoCAD and browse for axBlock.lsp which
you just created
Drag axBlock.lsp over your AutoCAD window.
Call axBlock.lsp via a script file. And scripts are nothing
really
but a simple textual file with *.scr extension. For that you just
need this line of code to be in your script file:
(load "C:\\axBlock.lsp")
After doing any of above three methods, as long as you type axBlock in AutoCAD and hit Enter, you will see the list of existing blocks.
Moreover, if you followed approach no.3 from above list, you can make a shortcut and call axBlock within the script file as well i.e. you load and call the function in one hit. If you want to do so, just add axBlock in the second line of your script code. Note there an extra SPACE after axBlock
I would like to have org-capture-template that does not insert certain text if a %-escape is blank. I am actually using the template with org-protocol and :immediate-finish, so I don't have the ability to manually edit and delete the blank line in a buffer. And sometimes I may select text on the web page and sometimes I may not. I am also just generally interested being able to make more dynamic templates.
Take this capture template as an example
(setq org-capture-templates
(quote (("w" "capture" entry (file "~/org/refile.org")
"* [[%:link][%:description]] :NOTE:\n%i\n%U\n" :immediate-finish t))))
With org-protocol://capture://w/http%3A%2F%2Fstackoverflow.com%2F/Stack%20Overflow/Hot%20Network%20Questions.
I get this which is fine.
* [[http://stackoverflow.com/][Stack Overflow]] :NOTE:
Hot Network Questions
[2014-01-12 Sun 13:01]
But if I don't have text selected like this example org-protocol://capture://w/http%3A%2F%2Fstackoverflow.com%2F/Stack%20Overflow/.
I get this:
* [[http://stackoverflow.com/][Stack Overflow]] :NOTE:
[2014-01-12 Sun 12:58]
I would like to know how to get rid of the blank line in this last example without having to use two templates.
My thought is to somehow use quote to build the string dynamically at template creation time, but I don't know how to get the value of %i to eval.
Use this auxiliary function:
(defun v-i-or-nothing ()
(let ((v-i (plist-get org-store-link-plist :initial)))
(if (equal v-i "")
""
(concat v-i "\n"))))
And this as capture template:
("w" "capture" entry (file "~/refile.org")
"* [[%:link][%:description]] :NOTE:\n%(v-i-or-nothing)%U\n"
:immediate-finish t)
I have Ruby Electric mode installed via ELPA.
I have visited a ruby file ~/test.rb
C-h m reveals that ruby electric mode is enabled as is font lock, see output below
Enabled minor modes: Auto-Compression Auto-Encryption Blink-Cursor Column-Number
Delete-Selection File-Name-Shadow Global-Font-Lock Global-Linum Iswitchb Line-Number
Menu-Bar Mouse-Wheel Shell-Dirtrack Tooltip Transient-Mark
However when I enter code like;
class Test
def foo()
I don't get any end auto inserted on hitting RET
UPDATE
I installed via package-list as that was recommended on the page I found, which I thought belonged to the author. Looking at the source of ~/emacs.d/elpa/ruby-electric-1.1/ruby-electric.el I see the following;
;; FIXME: it should be available in next versions of ruby-mode.el
(defun ruby-insert-end ()
(interactive)
(insert "end")
(ruby-indent-line t)
(end-of-line))
So it looks like I might have a bad file, will try another.
UPDATE
I used ruby-electric.el downloaded from http://svn.ruby-lang.org/repos/ruby/tags/v1_9_2_0/misc/ruby-electric.el
Linked to from this article http://appsintheopen.com/articles/1-setting-up-emacs-for-rails-development/part/7-emacs-ruby-foo
Then took this gist https://gist.github.com/1213051 adding this to ruby-electric.el
(defun ruby-insert-end ()
"Insert \"end\" at point and reindent current line."
(interactive)
(insert "end")
(ruby-indent-line t)
(end-of-line))
And this hook into my .emacs, it also appears to work without the hook
(add-hook 'ruby-mode-hook
(lambda ()
(require 'ruby-electric)
(ruby-electric-mode t)))
As discussed in this google groups thread; https://groups.google.com/forum/?fromgroups#!msg/emacs-on-rails/Cuh_x5eCK_M/KDwjY4K6X1YJ
Make sure it says REl in your emacs status bar.
I downloaded ruby-electric from here:
http://shylock.uw.hu/Emacs/ruby-electric.el
I then loaded the library into emacs, and went into a ruby file and activated
ruby electric with:
M-x ruby-electric-mode
When I type class and hit space it fills in the end automatically (running emacs 23). Maybe you want to give that version of ruby-electric.el a try, if you can't get the one from ELPA to work.
You need to include 'ruby-additional' to use 'ruby-electric':
https://github.com/ruby/ruby/blob/trunk/misc/ruby-additional.el
Should be merged in emacs some day.
I was trying some code from Elisp Cookbook, and I initially tought that this code:
(defun process-file (file)
"Read the contents of a file into a temp buffer and then do
something there."
(when (file-readable-p file)
(with-temp-buffer
(insert-file-contents file)
(goto-char (point-min))
(while (not (eobp))
;; do something here with buffer content
(forward-line)))))
Will create a new ( unnamed/unsaved ) buffer on my emacs window, having the contents of that file ( and maybe open it in the foreground ). However, this doesn't happen. Can you guide me towards this?
EDIT: I experimented a little, and got to this:
(defun myTest (file)
(interactive "f")
; check if file is readable
(when (file-readable-p file)
; create a new "untitled" buffer
(let ((myBuf (get-buffer-create "untitled")))
; make it the current displayed buffer
(switch-to-buffer myBuf)
(insert "Hello"))))
Is this the way to do it?
Since this is a buffer named "untitled", I can only have one of these in a session. Is there something I could use to have more than one, without resorting to random numbers?
The elisp way to generate a unique buffer name is to use generate-new-buffer-name. The documentation is:
(generate-new-buffer-name NAME &optional IGNORE)
Return a string that is the name of no existing buffer based on NAME.
If there is no live buffer named NAME, then return NAME. Otherwise
modify name by appending `', incrementing NUMBER (starting at
2) until an unused name is found, and then return that name. Optional
second argument IGNORE specifies a name that is okay to use (if it is
in the sequence to be tried) even if a buffer with that name exists.
I'm trying to figure out how to create a Compojure-based web-site with multilingual support. Is there any solutions like i18n or something like that?
The easiest way is to replace all your localized strings with a function calls like:
(i18n lang "help")
And implement that function to read localized string from a .properties file determined by lang parameter.
For that you don't need any libraries. It's a simple function.
To avoid reading files all the time you could read them in memory during your applications start with a def into a map named loaded-property-files where, lang is the key and the value is a map of message keys and appropriate localized messages.
This can be done like this:
(defn load-property-files [langs]
(let [default (into {} (read-properties "locale.properties"))]
(apply merge
(for [lang langs]
(assoc {} lang
(merge default
(into {} (read-properties (str "locale_" lang ".properties")))))))))
(def loaded-property-files
(load-property-files ["en" "es" "de"]))
If file loading performance is not a problem, but you'd like to be able to change the files more easily during runtime, just change the def to a function.
The function read-properties (originally from old clojure.contrib) looks like this:
(defn read-properties
"Read properties from file-able."
([fileable]
(into {} (map #(vector (keyword (key %)) (val %))
(try
(with-open [f (java.io.FileInputStream. (new java.io.File fileable))]
(doto (new java.util.Properties)
(.load f)))
(catch java.io.FileNotFoundException e {})))))
([fileable defaults] (merge (read-properties fileable) defaults)))
The localization string from default file would be used whenever that key isn't found in the specified map, i.e. new string that has just been added, and no one translated it in Spanish yet, would be shown in language from default locale.properties
Then your i18n function looks like this:
(defn i18n [lang code]
((loaded-property-files lang) code))
There is a new i18n library: https://github.com/ptaoussanis/tower with this rationale:
Tower is an attempt to present a simple, idiomatic internationalization and localization story for Clojure. It wraps standard Java functionality where possible, but it isn't afraid to step away from Java conventions when there's a good reason to.
I created clji18n for this, but I had to switch to other project before completing it. It's "almost" usable, you can give it a try.
kotarak's j18n (note that there is another j18n library for Java but they are different ones) seems good.
https://bitbucket.org/kotarak/j18n