How tool-bar button in emacs works? [duplicate] - emacs

This question already has answers here:
How to add a tool-bar button in emacs?
(2 answers)
Closed 8 years ago.
i have a problem to add a tool-bar button in emacs.
I can run it with eval-buffer but not with my .emacs. When i add it with eval-buffer my button leave my toolbar after a scroll.
;;; Code:
(defun omar-hotel ()
"another nonce menu function"
(interactive)
(message "hotel, motel, holiday inn"))
(define-key-after global-map [tool-bar omar-button]
'(menu-item "Hotel" omar-hotel
:image (image :type xpm :file "/usr/share/emacs/23.4/etc/images/jump-to.xpm")
:help "OMG Omar!"
))
i also tried to add-hook like that but that's doesn't works.
(add-hook 'after-init-hook
(lambda ()
(define-key-after global-map [tool-bar omar-button]
'(menu-item "Hotel" omar-hotel
:image (image :type xpm :file "/usr/share/emacs/23.4/etc/images/jump-to.xpm")
:help "OMG Omar!"
))
))

Hi i found a simple solution to add a toolbar button "spell" is the image in /usr/share/emacs/23.4/etc/images/
(defun omar-hotel ()
"another nonce menu function"
(interactive)
(message "hotel, motel, holiday inn"))
(tool-bar-add-item "spell" 'omar-hotel
'omar-hotel
:help "Run fonction omar-hotel")

Related

Is there a way to customize breadcrumbs in Emacs Orgmode?

When I set org-agenda-prefix-format with %b, I got all higher levels headline shown in the agenda .Is there any way to show only parent level, without other higher levels shown.
I have tried:
'((todo . " %-25(concat \"[\"(truncate-string-to-width (car (last
(org-get-outline-path))) 21 nil nil t) \"]\")"))
It works ok with todo.
However, when I tried on agenda:
'((agenda . " %-25(concat \"[\"(truncate-string-to-width (car (last
(org-get-outline-path))) 21 nil nil t) \"]\")"))
my custom command:
("n" "Agenda and all TODOs"
((agenda "" nil)
(alltodo "" nil))
nil)
did not work, only agenda but no todo shown.
update:
If there is no agenda items for today, the agenda view shows ok with both todo and agenda. However, If there is an agenda items for today, the todo won't show any more. Does my org-agenda-prefix-format config affect the timeline or something? This really makes me confused.

Get a view of scheduled tasks excluding some TODO states on Org Mode

Here are the todo states I use (on GNU Emacs 24.5.1):
(setq org-todo-keywords '((type "TODO" "NEXT" "DONE" "STARTED" "WAITING" "FROZEN" "REFERENCE" "CANCELLED" "DELEGATED")))
I would like to create a custom view showing all the scheduled tasks for the current week (next 8 days) that have TODO, NEXT, STARTED, WAITING, FROZEN, REFERENCE, or DELEGATED as a todo state.
(setq org-agenda-custom-commands
'(("8" "Scheduled this week"
((agenda ""
((org-agenda-start-day "+0")
(org-agenda-span 8)
(org-agenda-skip-function '(org-agenda-skip-entry-if 'todo '("DONE" "CANCELLED")))
)
))
))
)

Leaflet Popups with Clojurescript

I'm pretty sure this is a conceptual error, but I'm not sure where I'm making the incorrect call.
Following the leaflet tutorial, I'm trying to create a popup on a map. Per the tutorial, this is a simple operation
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(mymap);
}
mymap.on('click', onMapClick);
However, when I translate this into clojurescript, I receive the following error:
Uncaught TypeError: t.openPopup is not a function
I'm 100% positive I'm calling the javascript incorrectly. I'm doing the following:
(defn onMapClick [e]
(let [popup (js/L.Popup.)]
(-> popup
(.setLatLng (.-latlng e))
(.setContent (str "You clicked the map at " (.-latlng e)))
(.openOn map))))
And then I call this as:
(.on map "click" onMapClick)
where map is correctly defined. (I say correctly because I am able to draw polygons and create popups that are bound to those polygons with .bindPopup)
I was thinking of not relying on return values at all. Just relying on the call sequence:
(defn onMapClick [e]
(let [popup (js/L.Popup.)]
(.setLatLng popup (.-latlng e))
(.setContent popup (str "You clicked the map at " (.-latlng e)))
(.openOn popup map)))
If the docs say that these js setter functions return popup then this won't make much of an answer!
You should be able to isolate the problem down to just one function call??

Capturing clicks in label_widget in expander (lablgtk)

In lablgtk, I have an Expander widget to which I added a button as part of its label, as in this picture:
However, I'm unable to capture clicks to this button, since all of them seem to be captured by the Expander object itself.
I even tried adding an event box between the expander and the button (similarly to what is recommended for clickable GLabels), but that did not help.
Is there a way to ensure the button receives the signal?
Here's a self-contained example to illustrate this: clicking on the button only prints expander activated!, but never button clicked!.
let main () =
(* create expander, a label_widget, and a button *)
let expander = GBin.expander () in
let expander_label = GMisc.label ~text:"expander" () in
let expander_label_widget = GPack.hbox () in
let button = GButton.button ~stock:`OK () in
(* add button to label_widget, and label_widget to expander *)
expander_label_widget#add expander_label#coerce;
expander_label_widget#add button#coerce;
expander#set_label_widget expander_label_widget#coerce;
(* add events for both the button and the expander *)
ignore (button#connect#clicked
~callback:(fun () ->
Format.printf "button clicked!#."));
ignore (expander#connect#activate
~callback:(fun () ->
Format.printf "expander activated!#."));
(* create window and add expander *)
let window = GWindow.window () in
window#add expander#coerce;
ignore (window#connect#destroy
~callback:(fun () -> GMain.Main.quit ()));
(* show result *)
window#show ();
GMain.Main.main ()
let () =
ignore (GtkMain.Main.init ());
main ()
This seems to be a bug in GTK+.
There's a workaround described here but it's in C.
You have to add the following OCaml code to your main function. It worked for me.
GMain.Idle.add (fun () ->
let dummy = GButton.button ~stock:`OK () in
expander#set_label_widget dummy#coerce ;
expander#set_label_widget expander_label_widget#coerce ;
false) ;

Remove the gnu style indentation from struct functions in c++

I am using emacs. I have set the indentation style as "linux", but for functions in structm somehow the indentation style turns out to be gnu. How do I remove it?
What I have is this:
struct Graph{
vector<lld> *adj;
lld V;
Graph(lld V_)
{
V=V_;
adj=new vector<lld>[V+1];
}
}
What I want is this:
struct Graph{
vector<lld> *adj;
lld V;
Graph(lld V_)
{
V=V_;
adj=new vector<lld>[V+1];
}
}
This is a way to achieve that:
(add-hook 'c-mode-common-hook (lambda () (c-set-offset 'inline-open 0)))